Generated by Cython 0.19 on Wed Sep 11 16:25:22 2013

Raw output: water_algorithm_cython.c

 1: #cython: wraparound=False
  /* "water_algorithm_cython.pyx":1
 * #cython: wraparound=False             # <<<<<<<<<<<<<<
 * #cython: nonecheck=False
 * #cython: infer_types=True
 */
  __pyx_t_19 = PyDict_New(); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_19));
  if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_19)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_19)); __pyx_t_19 = 0;
 2: #cython: nonecheck=False
 3: #cython: infer_types=True
 4: #cython: boundscheck=False
 5: #cython: c_line_in_traceback=False
 6: import numpy as np
  /* "water_algorithm_cython.pyx":6
 * #cython: boundscheck=False
 * #cython: c_line_in_traceback=False
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * np.import_array()
 */
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__np, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 7: cimport numpy as np
 8: np.import_array()
  /* "water_algorithm_cython.pyx":8
 * import numpy as np
 * cimport numpy as np
 * np.import_array()             # <<<<<<<<<<<<<<
 * import scipy
 * import math
 */
  import_array();
 9: import scipy
  /* "water_algorithm_cython.pyx":9
 * cimport numpy as np
 * np.import_array()
 * import scipy             # <<<<<<<<<<<<<<
 * import math
 * cimport cython
 */
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__scipy), 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__scipy, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 10: import math
  /* "water_algorithm_cython.pyx":10
 * np.import_array()
 * import scipy
 * import math             # <<<<<<<<<<<<<<
 * cimport cython
 * 
 */
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__math), 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__math, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 11: cimport cython
 12: 
 13: import ase
  /* "water_algorithm_cython.pyx":13
 * cimport cython
 * 
 * import ase             # <<<<<<<<<<<<<<
 * import os
 * 
 */
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__ase), 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__ase, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 14: import os
  /* "water_algorithm_cython.pyx":14
 * 
 * import ase
 * import os             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__os, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 15: 
 16: 
 17: #from mpi4py import MPI
 18: from mpi4py cimport MPI
 19: from mpi4py cimport mpi_c
 20: from time import time
  /* "water_algorithm_cython.pyx":20
 * from mpi4py cimport MPI
 * from mpi4py cimport mpi_c
 * from time import time             # <<<<<<<<<<<<<<
 * #from result_group_cython import ResultGroup, merge_groups
 * from .result_group_cython cimport ResultGroup, merge_groups
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__time));
  PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__time));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__time));
  __pyx_t_6 = __Pyx_Import(((PyObject *)__pyx_n_s__time), ((PyObject *)__pyx_t_5), -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s__time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__time, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 21: #from result_group_cython import ResultGroup, merge_groups
 22: from .result_group_cython cimport ResultGroup, merge_groups
 23: from .graph_invariants_cython cimport get_invariants, Invariant, InvariantTerm, print_invariants, initialize_new_indexing
 24: from help_methods import *
  /* "water_algorithm_cython.pyx":24
 * from .result_group_cython cimport ResultGroup, merge_groups
 * from .graph_invariants_cython cimport get_invariants, Invariant, InvariantTerm, print_invariants, initialize_new_indexing
 * from help_methods import *             # <<<<<<<<<<<<<<
 * 
 * from .symmetries.symmetry_operation_cython cimport SymmetryOperation, do_symmetry_operation_filtering, remove_earlier_found, mark_earlier_found, all_found, get_sub_symmetry_level_improved
 */
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_n_s_241));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_n_s_241));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_241));
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__help_methods), ((PyObject *)__pyx_t_6), -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  if (__pyx_import_star(__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 25: 
 26: from .symmetries.symmetry_operation_cython cimport SymmetryOperation, do_symmetry_operation_filtering, remove_earlier_found, mark_earlier_found, all_found, get_sub_symmetry_level_improved
 27: from .symmetries.self_symmetry_group_cython cimport SelfSymmetryGroup
 28: from .symmetries.interface_cython cimport find_symmetry_operations, print_symmetry_operations
 29: from symmetries.interface_cython import get_moments_of_inertia, get_closest_positions
  /* "water_algorithm_cython.pyx":29
 * from .symmetries.self_symmetry_group_cython cimport SelfSymmetryGroup
 * from .symmetries.interface_cython cimport find_symmetry_operations, print_symmetry_operations
 * from symmetries.interface_cython import get_moments_of_inertia, get_closest_positions             # <<<<<<<<<<<<<<
 * from cpython cimport bool
 * 
 */
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_n_s_118));
  PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s_118));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_118));
  __Pyx_INCREF(((PyObject *)__pyx_n_s_135));
  PyList_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s_135));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s_135));
  __pyx_t_6 = __Pyx_Import(((PyObject *)__pyx_n_s_242), ((PyObject *)__pyx_t_5), -1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_118); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_118, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_135); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_135, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 30: from cpython cimport bool
 31: 
 32: DTYPE = np.uint8
  /* "water_algorithm_cython.pyx":32
 * from cpython cimport bool
 * 
 * DTYPE = np.uint8             # <<<<<<<<<<<<<<
 * DTYPE2 = np.int8
 * DTYPE4 = np.float
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__uint8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__DTYPE, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 33: DTYPE2 = np.int8
  /* "water_algorithm_cython.pyx":33
 * 
 * DTYPE = np.uint8
 * DTYPE2 = np.int8             # <<<<<<<<<<<<<<
 * DTYPE4 = np.float
 * cdef MPI.Comm comm = MPI.COMM_WORLD
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__DTYPE2, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 34: DTYPE4 = np.float
  /* "water_algorithm_cython.pyx":34
 * DTYPE = np.uint8
 * DTYPE2 = np.int8
 * DTYPE4 = np.float             # <<<<<<<<<<<<<<
 * cdef MPI.Comm comm = MPI.COMM_WORLD
 * cdef public unsigned char size = comm.Get_size()
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__float); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__DTYPE4, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 35: cdef MPI.Comm comm = MPI.COMM_WORLD
  /* "water_algorithm_cython.pyx":35
 * DTYPE2 = np.int8
 * DTYPE4 = np.float
 * cdef MPI.Comm comm = MPI.COMM_WORLD             # <<<<<<<<<<<<<<
 * cdef public unsigned char size = comm.Get_size()
 * cdef public unsigned char rank = comm.Get_rank()
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__MPI); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__COMM_WORLD); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_6mpi4py_3MPI_Comm))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_XGOTREF(((PyObject *)__pyx_v_22water_algorithm_cython_comm));
  __Pyx_DECREF(((PyObject *)__pyx_v_22water_algorithm_cython_comm));
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_v_22water_algorithm_cython_comm = ((struct PyMPICommObject *)__pyx_t_6);
  __pyx_t_6 = 0;
 36: cdef public unsigned char size = comm.Get_size()
  /* "water_algorithm_cython.pyx":36
 * DTYPE4 = np.float
 * cdef MPI.Comm comm = MPI.COMM_WORLD
 * cdef public unsigned char size = comm.Get_size()             # <<<<<<<<<<<<<<
 * cdef public unsigned char rank = comm.Get_rank()
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__Get_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_PyInt_AsUnsignedChar(__pyx_t_5); if (unlikely((__pyx_t_7 == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  size = __pyx_t_7;
 37: cdef public unsigned char rank = comm.Get_rank()
  /* "water_algorithm_cython.pyx":37
 * cdef MPI.Comm comm = MPI.COMM_WORLD
 * cdef public unsigned char size = comm.Get_size()
 * cdef public unsigned char rank = comm.Get_rank()             # <<<<<<<<<<<<<<
 * 
 * cdef class WaterAlgorithm:
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__Get_rank); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = __Pyx_PyInt_AsUnsignedChar(__pyx_t_6); if (unlikely((__pyx_t_7 == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  rank = __pyx_t_7;
 38: 
 39: cdef class WaterAlgorithm:
/* "water_algorithm_cython.pyx":39
 * cdef public unsigned char rank = comm.Get_rank()
 * 
 * cdef class WaterAlgorithm:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, filename=""):
 */

struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm {
  void (*load_invariants)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *);
  void (*initialize_symmetry_operations)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *);
  PyArrayObject *(*get_symmetries)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, PyArrayObject *, PyArrayObject *, PyObject *);
  PyBoolObject *(*water_orientation_is_valid)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, signed char, PyArrayObject *, unsigned char);
  PyArrayObject *(*handle_molecule_algorithm_2)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, unsigned char, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int, int *);
  PyObject *(*do_initial_grouping)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, PyArrayObject *, int, int);
  PyArrayObject *(*remove_symmetric_results)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, __Pyx_memviewslice, unsigned char, PyObject *, int, PyObject *, int, PyObject *, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *, int, int);
  int (*is_symmetric_with_another_result)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, struct __pyx_obj_19result_group_cython_ResultGroup *, __Pyx_memviewslice, signed int, int, PyObject *, int, PyObject *, int, PyObject *, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *, __Pyx_memviewslice);
  PyArrayObject *(*perform_2)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, PyArrayObject *, unsigned char, PyArrayObject *, PyArrayObject *, signed char, signed char, PyObject *);
  __Pyx_memviewslice (*get_single_molecule_dipole_moment)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, unsigned int, __pyx_t_22water_algorithm_cython_DTYPE2_t, unsigned int, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice);
  PyArrayObject *(*remove_symmetries_no_invariants)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, PyArrayObject *, PyArrayObject *, unsigned char, PyObject *, PyObject *, PyBoolObject *);
  __Pyx_memviewslice (*remove_symmetries_for_single_group)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, struct __pyx_obj_19result_group_cython_ResultGroup *, __Pyx_memviewslice, int, int, PyObject *, PyObject *, int, PyObject *, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *, int *);
  struct __pyx_obj_19result_group_cython_ResultGroup *(*single_wo_initial_grouping)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, __Pyx_memviewslice, __Pyx_memviewslice);
  PyObject *(*handle_self_symmetry_group)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *, PyObject *, PyObject *, __Pyx_memviewslice, PyObject *, int, unsigned char, struct __pyx_obj_19result_group_cython_ResultGroup *, int, int, __Pyx_memviewslice, int, __Pyx_memviewslice);
  PyObject *(*handle_self_symmetry_groups)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, __Pyx_memviewslice, unsigned char, PyObject *, PyObject *, int, int, int, __Pyx_memviewslice);
  int (*water_orientation_is_valid_using_possible_combinations)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, signed char, PyArrayObject *, unsigned char);
  int (*additional_requirements_met)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, signed char, __Pyx_memviewslice, unsigned char, int __pyx_skip_dispatch);
  __Pyx_memviewslice (*get_total_dipole_moment)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, __Pyx_memviewslice, int __pyx_skip_dispatch);
  PyArrayObject *(*get_single_molecule_hydrogen_coordinates)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, unsigned int, __pyx_t_22water_algorithm_cython_DTYPE2_t, unsigned int, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch);
  PyArrayObject *(*get_total_dipole_moments)(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *, __Pyx_memviewslice, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *__pyx_vtabptr_22water_algorithm_cython_WaterAlgorithm;
 40: 
 41:     def __init__(self, filename=""):
/* "water_algorithm_cython.pyx":41
 * cdef class WaterAlgorithm:
 * 
 *     def __init__(self, filename=""):             # <<<<<<<<<<<<<<
 *         """
 *             File name is the filename having the oxygen structure
 */

static int __pyx_pf_22water_algorithm_cython_14WaterAlgorithm___init__(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_filename) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
 42:         """
 43:             File name is the filename having the oxygen structure
 44:         """
 45:         self.filename = filename
  /* "water_algorithm_cython.pyx":45
 *             File name is the filename having the oxygen structure
 *         """
 *         self.filename = filename             # <<<<<<<<<<<<<<
 *         if filename != "":
 *             self.initialize()
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_filename))||((__pyx_v_filename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_filename)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __Pyx_GOTREF(__pyx_v_self->filename);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->filename));
  __pyx_v_self->filename = ((PyObject*)__pyx_v_filename);
 46:         if filename != "":
  /* "water_algorithm_cython.pyx":46
 *         """
 *         self.filename = filename
 *         if filename != "":             # <<<<<<<<<<<<<<
 *             self.initialize()
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_filename, ((PyObject *)__pyx_kp_s_1), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
 47:             self.initialize()
    /* "water_algorithm_cython.pyx":47
 *         self.filename = filename
 *         if filename != "":
 *             self.initialize()             # <<<<<<<<<<<<<<
 * 
 *     def initialize(self, periodic=None, bool slab=False, cell=None, store_bond_variables=False, O_H_distance=1.0, O_O_distance=2.70, intermediate_saves=None, char* folder="", group_saves=None, signed char charge=0, signed char dissosiation_count=0, do_symmetry_check = None, order = None, options = None, preset_bond_values = None, scale = False):
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__initialize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_3initialize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_2initialize[] = "\n            periodic: is the cell periodic\n            cell : the x y z lengths of the cell i an array\n            NOTE: needed only if the periodic is True\n            preset_bond_values: 3-dimension dict containing the values for given bonds so that key1 is the number of first atom,\n                                key2 the number of second atom, and key3 the periodicity axis, if key3 is not given the periodicity axis is 13 (no periodicity).\n                                The value is either 1 or -1.\n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_3initialize(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_periodic = 0;
  CYTHON_UNUSED PyBoolObject *__pyx_v_slab = 0;
  PyObject *__pyx_v_cell = 0;
  PyObject *__pyx_v_store_bond_variables = 0;
  PyObject *__pyx_v_O_H_distance = 0;
  PyObject *__pyx_v_O_O_distance = 0;
  PyObject *__pyx_v_intermediate_saves = 0;
  char *__pyx_v_folder;
  PyObject *__pyx_v_group_saves = 0;
  signed char __pyx_v_charge;
  signed char __pyx_v_dissosiation_count;
  PyObject *__pyx_v_do_symmetry_check = 0;
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_v_preset_bond_values = 0;
  PyObject *__pyx_v_scale = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__periodic,&__pyx_n_s__slab,&__pyx_n_s__cell,&__pyx_n_s_2,&__pyx_n_s__O_H_distance,&__pyx_n_s__O_O_distance,&__pyx_n_s__intermediate_saves,&__pyx_n_s__folder,&__pyx_n_s__group_saves,&__pyx_n_s__charge,&__pyx_n_s__dissosiation_count,&__pyx_n_s__do_symmetry_check,&__pyx_n_s__order,&__pyx_n_s__options,&__pyx_n_s__preset_bond_values,&__pyx_n_s__scale,0};
    PyObject* values[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 48: 
 49:     def initialize(self, periodic=None, bool slab=False, cell=None, store_bond_variables=False, O_H_distance=1.0, O_O_distance=2.70, intermediate_saves=None, char* folder="", group_saves=None, signed char charge=0, signed char dissosiation_count=0, do_symmetry_check = None, order = None, options = None, preset_bond_values = None, scale = False):
    /* "water_algorithm_cython.pyx":49
 *             self.initialize()
 * 
 *     def initialize(self, periodic=None, bool slab=False, cell=None, store_bond_variables=False, O_H_distance=1.0, O_O_distance=2.70, intermediate_saves=None, char* folder="", group_saves=None, signed char charge=0, signed char dissosiation_count=0, do_symmetry_check = None, order = None, options = None, preset_bond_values = None, scale = False):             # <<<<<<<<<<<<<<
 *         """
 *             periodic: is the cell periodic
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = (PyObject *)__pyx_k_3;
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_4;
    values[4] = __pyx_k_5;
    values[5] = __pyx_k_6;
    values[6] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);
    values[11] = ((PyObject *)Py_None);
    values[12] = ((PyObject *)Py_None);
    values[13] = ((PyObject *)Py_None);
    values[14] = ((PyObject *)Py_None);
    values[15] = __pyx_k_7;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
        case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
        case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slab);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_2);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__O_H_distance);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__O_O_distance);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__intermediate_saves);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__folder);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group_saves);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__charge);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dissosiation_count);
          if (value) { values[10] = value; kw_args--; }
        }
        case 11:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__do_symmetry_check);
          if (value) { values[11] = value; kw_args--; }
        }
        case 12:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__order);
          if (value) { values[12] = value; kw_args--; }
        }
        case 13:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__options);
          if (value) { values[13] = value; kw_args--; }
        }
        case 14:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__preset_bond_values);
          if (value) { values[14] = value; kw_args--; }
        }
        case 15:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scale);
          if (value) { values[15] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "initialize") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15);
        case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14);
        case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13);
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_periodic = values[0];
    __pyx_v_slab = ((PyBoolObject *)values[1]);
    __pyx_v_cell = values[2];
    __pyx_v_store_bond_variables = values[3];
    __pyx_v_O_H_distance = values[4];
    __pyx_v_O_O_distance = values[5];
    __pyx_v_intermediate_saves = values[6];
    if (values[7]) {
      __pyx_v_folder = __Pyx_PyObject_AsString(values[7]); if (unlikely((!__pyx_v_folder) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_folder = ((char *)__pyx_k_1);
    }
    __pyx_v_group_saves = values[8];
    if (values[9]) {
      __pyx_v_charge = __Pyx_PyInt_AsSignedChar(values[9]); if (unlikely((__pyx_v_charge == (signed char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_charge = ((signed char)0);
    }
    if (values[10]) {
      __pyx_v_dissosiation_count = __Pyx_PyInt_AsSignedChar(values[10]); if (unlikely((__pyx_v_dissosiation_count == (signed char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_dissosiation_count = ((signed char)0);
    }
    __pyx_v_do_symmetry_check = values[11];
    __pyx_v_order = values[12];
    __pyx_v_options = values[13];
    __pyx_v_preset_bond_values = values[14];
    __pyx_v_scale = values[15];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("initialize", 0, 0, 16, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.initialize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slab), __pyx_ptype_7cpython_4bool_bool, 1, "slab", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_2initialize(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_periodic, __pyx_v_slab, __pyx_v_cell, __pyx_v_store_bond_variables, __pyx_v_O_H_distance, __pyx_v_O_O_distance, __pyx_v_intermediate_saves, __pyx_v_folder, __pyx_v_group_saves, __pyx_v_charge, __pyx_v_dissosiation_count, __pyx_v_do_symmetry_check, __pyx_v_order, __pyx_v_options, __pyx_v_preset_bond_values, __pyx_v_scale);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_2initialize(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_periodic, CYTHON_UNUSED PyBoolObject *__pyx_v_slab, PyObject *__pyx_v_cell, PyObject *__pyx_v_store_bond_variables, PyObject *__pyx_v_O_H_distance, PyObject *__pyx_v_O_O_distance, PyObject *__pyx_v_intermediate_saves, char *__pyx_v_folder, PyObject *__pyx_v_group_saves, signed char __pyx_v_charge, signed char __pyx_v_dissosiation_count, PyObject *__pyx_v_do_symmetry_check, PyObject *__pyx_v_order, PyObject *__pyx_v_options, PyObject *__pyx_v_preset_bond_values, PyObject *__pyx_v_scale) {
  PyObject *__pyx_v_average = NULL;
  PyObject *__pyx_v_scaling_factor = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize", 0);

  /* "water_algorithm_cython.pyx":49
 *             self.initialize()
 * 
 *     def initialize(self, periodic=None, bool slab=False, cell=None, store_bond_variables=False, O_H_distance=1.0, O_O_distance=2.70, intermediate_saves=None, char* folder="", group_saves=None, signed char charge=0, signed char dissosiation_count=0, do_symmetry_check = None, order = None, options = None, preset_bond_values = None, scale = False):             # <<<<<<<<<<<<<<
 *         """
 *             periodic: is the cell periodic
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_k_3 = ((PyBoolObject *)__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_4 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_5 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(2.70); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_6 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_7 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
 50:         """
 51:             periodic: is the cell periodic
 52:             cell : the x y z lengths of the cell i an array
 53:             NOTE: needed only if the periodic is True
 54:             preset_bond_values: 3-dimension dict containing the values for given bonds so that key1 is the number of first atom,
 55:                                 key2 the number of second atom, and key3 the periodicity axis, if key3 is not given the periodicity axis is 13 (no periodicity).
 56:                                 The value is either 1 or -1.
 57:         """
 58: 
 59:         self.invariant_count = 20
  /* "water_algorithm_cython.pyx":59
 *         """
 * 
 *         self.invariant_count = 20             # <<<<<<<<<<<<<<
 *         if folder is not None:
 *             self.folder = folder
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__invariant_count, __pyx_int_20) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 60:         if folder is not None:
  /* "water_algorithm_cython.pyx":60
 * 
 *         self.invariant_count = 20
 *         if folder is not None:             # <<<<<<<<<<<<<<
 *             self.folder = folder
 *         if options is not None:
 */
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_folder); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = (((PyObject*)__pyx_t_1) != ((PyObject*)Py_None));
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (__pyx_t_2) {
 61:             self.folder = folder
    /* "water_algorithm_cython.pyx":61
 *         self.invariant_count = 20
 *         if folder is not None:
 *             self.folder = folder             # <<<<<<<<<<<<<<
 *         if options is not None:
 *             self.set_parameters(options)
 */
    __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_folder); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __Pyx_GOTREF(__pyx_v_self->folder);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->folder));
    __pyx_v_self->folder = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 62:         if options is not None:
  /* "water_algorithm_cython.pyx":62
 *         if folder is not None:
 *             self.folder = folder
 *         if options is not None:             # <<<<<<<<<<<<<<
 *             self.set_parameters(options)
 *         if periodic is not None:
 */
  __pyx_t_2 = (__pyx_v_options != Py_None);
  if (__pyx_t_2) {
 63:             self.set_parameters(options)
    /* "water_algorithm_cython.pyx":63
 *             self.folder = folder
 *         if options is not None:
 *             self.set_parameters(options)             # <<<<<<<<<<<<<<
 *         if periodic is not None:
 *             self.periodic = self.handle_periodic_input(periodic)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__set_parameters); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_options);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_options);
    __Pyx_GIVEREF(__pyx_v_options);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;
 64:         if periodic is not None:
  /* "water_algorithm_cython.pyx":64
 *         if options is not None:
 *             self.set_parameters(options)
 *         if periodic is not None:             # <<<<<<<<<<<<<<
 *             self.periodic = self.handle_periodic_input(periodic)
 *         else:
 */
  __pyx_t_2 = (__pyx_v_periodic != Py_None);
  if (__pyx_t_2) {
 65:             self.periodic = self.handle_periodic_input(periodic)
    /* "water_algorithm_cython.pyx":65
 *             self.set_parameters(options)
 *         if periodic is not None:
 *             self.periodic = self.handle_periodic_input(periodic)             # <<<<<<<<<<<<<<
 *         else:
 *             self.periodic = False
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_periodic);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_periodic);
    __Pyx_GIVEREF(__pyx_v_periodic);
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L5;
  }
  /*else*/ {
 66:         else:
 67:             self.periodic = False
    /* "water_algorithm_cython.pyx":67
 *             self.periodic = self.handle_periodic_input(periodic)
 *         else:
 *             self.periodic = False             # <<<<<<<<<<<<<<
 *         self.O_H_distance = O_H_distance
 *         self.O_O_distance = O_O_distance
 */
    __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;
 68:         self.O_H_distance = O_H_distance
  /* "water_algorithm_cython.pyx":68
 *         else:
 *             self.periodic = False
 *         self.O_H_distance = O_H_distance             # <<<<<<<<<<<<<<
 *         self.O_O_distance = O_O_distance
 *         if intermediate_saves is not None:
 */
  __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_v_O_H_distance); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->O_H_distance = __pyx_t_5;
 69:         self.O_O_distance = O_O_distance
  /* "water_algorithm_cython.pyx":69
 *             self.periodic = False
 *         self.O_H_distance = O_H_distance
 *         self.O_O_distance = O_O_distance             # <<<<<<<<<<<<<<
 *         if intermediate_saves is not None:
 *             self.intermediate_saves = np.array(intermediate_saves, dtype=DTYPE)
 */
  __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_v_O_O_distance); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->O_O_distance = __pyx_t_5;
 70:         if intermediate_saves is not None:
  /* "water_algorithm_cython.pyx":70
 *         self.O_H_distance = O_H_distance
 *         self.O_O_distance = O_O_distance
 *         if intermediate_saves is not None:             # <<<<<<<<<<<<<<
 *             self.intermediate_saves = np.array(intermediate_saves, dtype=DTYPE)
 *         else:
 */
  __pyx_t_2 = (__pyx_v_intermediate_saves != Py_None);
  if (__pyx_t_2) {
 71:             self.intermediate_saves = np.array(intermediate_saves, dtype=DTYPE)
    /* "water_algorithm_cython.pyx":71
 *         self.O_O_distance = O_O_distance
 *         if intermediate_saves is not None:
 *             self.intermediate_saves = np.array(intermediate_saves, dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         else:
 *             self.intermediate_saves = None
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_intermediate_saves);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_intermediate_saves);
    __Pyx_GIVEREF(__pyx_v_intermediate_saves);
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->intermediate_saves);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->intermediate_saves));
    __pyx_v_self->intermediate_saves = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L6;
  }
  /*else*/ {
 72:         else:
 73:             self.intermediate_saves = None
    /* "water_algorithm_cython.pyx":73
 *             self.intermediate_saves = np.array(intermediate_saves, dtype=DTYPE)
 *         else:
 *             self.intermediate_saves = None             # <<<<<<<<<<<<<<
 * 
 *         if group_saves is not None:
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->intermediate_saves);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->intermediate_saves));
    __pyx_v_self->intermediate_saves = ((PyArrayObject *)Py_None);
  }
  __pyx_L6:;
 74: 
 75:         if group_saves is not None:
  /* "water_algorithm_cython.pyx":75
 *             self.intermediate_saves = None
 * 
 *         if group_saves is not None:             # <<<<<<<<<<<<<<
 *             self.group_saves = np.array(group_saves, dtype=DTYPE)
 *         else:
 */
  __pyx_t_2 = (__pyx_v_group_saves != Py_None);
  if (__pyx_t_2) {
 76:             self.group_saves = np.array(group_saves, dtype=DTYPE)
    /* "water_algorithm_cython.pyx":76
 * 
 *         if group_saves is not None:
 *             self.group_saves = np.array(group_saves, dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         else:
 *             self.group_saves = None
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__array); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_group_saves);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_group_saves);
    __Pyx_GIVEREF(__pyx_v_group_saves);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->group_saves);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->group_saves));
    __pyx_v_self->group_saves = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L7;
  }
  /*else*/ {
 77:         else:
 78:             self.group_saves = None
    /* "water_algorithm_cython.pyx":78
 *             self.group_saves = np.array(group_saves, dtype=DTYPE)
 *         else:
 *             self.group_saves = None             # <<<<<<<<<<<<<<
 *         self.slab = False
 *         self.charge = charge
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->group_saves);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->group_saves));
    __pyx_v_self->group_saves = ((PyArrayObject *)Py_None);
  }
  __pyx_L7:;
 79:         self.slab = False
  /* "water_algorithm_cython.pyx":79
 *         else:
 *             self.group_saves = None
 *         self.slab = False             # <<<<<<<<<<<<<<
 *         self.charge = charge
 *         self.dissosiation_count = dissosiation_count
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__slab, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 80:         self.charge = charge
  /* "water_algorithm_cython.pyx":80
 *             self.group_saves = None
 *         self.slab = False
 *         self.charge = charge             # <<<<<<<<<<<<<<
 *         self.dissosiation_count = dissosiation_count
 *         self.oxygen_coordinates = self.get_all_oxygen_coordinates()
 */
  __pyx_v_self->charge = __pyx_v_charge;
 81:         self.dissosiation_count = dissosiation_count
  /* "water_algorithm_cython.pyx":81
 *         self.slab = False
 *         self.charge = charge
 *         self.dissosiation_count = dissosiation_count             # <<<<<<<<<<<<<<
 *         self.oxygen_coordinates = self.get_all_oxygen_coordinates()
 *         if self.oxygen_coordinates == None:
 */
  __pyx_v_self->dissosiation_count = __pyx_v_dissosiation_count;
 82:         self.oxygen_coordinates = self.get_all_oxygen_coordinates()
  /* "water_algorithm_cython.pyx":82
 *         self.charge = charge
 *         self.dissosiation_count = dissosiation_count
 *         self.oxygen_coordinates = self.get_all_oxygen_coordinates()             # <<<<<<<<<<<<<<
 *         if self.oxygen_coordinates == None:
 *             self.atoms = self.read_oxygen_raft_from_file()
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->oxygen_coordinates);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  __pyx_v_self->oxygen_coordinates = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 83:         if self.oxygen_coordinates == None:
  /* "water_algorithm_cython.pyx":83
 *         self.dissosiation_count = dissosiation_count
 *         self.oxygen_coordinates = self.get_all_oxygen_coordinates()
 *         if self.oxygen_coordinates == None:             # <<<<<<<<<<<<<<
 *             self.atoms = self.read_oxygen_raft_from_file()
 *             self.oxygen_coordinates = self.atoms.get_positions()
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->oxygen_coordinates), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
 84:             self.atoms = self.read_oxygen_raft_from_file()
    /* "water_algorithm_cython.pyx":84
 *         self.oxygen_coordinates = self.get_all_oxygen_coordinates()
 *         if self.oxygen_coordinates == None:
 *             self.atoms = self.read_oxygen_raft_from_file()             # <<<<<<<<<<<<<<
 *             self.oxygen_coordinates = self.atoms.get_positions()
 *             self.periodic = self.atoms.get_pbc()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->atoms);
    __Pyx_DECREF(__pyx_v_self->atoms);
    __pyx_v_self->atoms = __pyx_t_3;
    __pyx_t_3 = 0;
 85:             self.oxygen_coordinates = self.atoms.get_positions()
    /* "water_algorithm_cython.pyx":85
 *         if self.oxygen_coordinates == None:
 *             self.atoms = self.read_oxygen_raft_from_file()
 *             self.oxygen_coordinates = self.atoms.get_positions()             # <<<<<<<<<<<<<<
 *             self.periodic = self.atoms.get_pbc()
 *             self.initialize_cell(atoms.get_cell())
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->oxygen_coordinates);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    __pyx_v_self->oxygen_coordinates = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
 86:             self.periodic = self.atoms.get_pbc()
    /* "water_algorithm_cython.pyx":86
 *             self.atoms = self.read_oxygen_raft_from_file()
 *             self.oxygen_coordinates = self.atoms.get_positions()
 *             self.periodic = self.atoms.get_pbc()             # <<<<<<<<<<<<<<
 *             self.initialize_cell(atoms.get_cell())
 *         else:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__get_pbc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 87:             self.initialize_cell(atoms.get_cell())
    /* "water_algorithm_cython.pyx":87
 *             self.oxygen_coordinates = self.atoms.get_positions()
 *             self.periodic = self.atoms.get_pbc()
 *             self.initialize_cell(atoms.get_cell())             # <<<<<<<<<<<<<<
 *         else:
 *             self.initialize_cell(cell)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__initialize_cell); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__atoms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__get_cell); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L8;
  }
  /*else*/ {
 88:         else:
 89:             self.initialize_cell(cell)
    /* "water_algorithm_cython.pyx":89
 *             self.initialize_cell(atoms.get_cell())
 *         else:
 *             self.initialize_cell(cell)             # <<<<<<<<<<<<<<
 *             self.atoms = ase.Atoms("O%i" % len(self.oxygen_coordinates), positions=self.oxygen_coordinates, cell=self.cell, pbc = periodic)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__initialize_cell); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_cell);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_cell);
    __Pyx_GIVEREF(__pyx_v_cell);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 90:             self.atoms = ase.Atoms("O%i" % len(self.oxygen_coordinates), positions=self.oxygen_coordinates, cell=self.cell, pbc = periodic)
    /* "water_algorithm_cython.pyx":90
 *         else:
 *             self.initialize_cell(cell)
 *             self.atoms = ase.Atoms("O%i" % len(self.oxygen_coordinates), positions=self.oxygen_coordinates, cell=self.cell, pbc = periodic)             # <<<<<<<<<<<<<<
 * 
 *         self.oxygen_coordinates += [self.x_offset, self.y_offset, self.z_offset]
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__Atoms); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_7 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__positions), ((PyObject *)__pyx_v_self->oxygen_coordinates)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cell), __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pbc), __pyx_v_periodic) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->atoms);
    __Pyx_DECREF(__pyx_v_self->atoms);
    __pyx_v_self->atoms = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_L8:;
 91: 
 92:         self.oxygen_coordinates += [self.x_offset, self.y_offset, self.z_offset]
  /* "water_algorithm_cython.pyx":92
 *             self.atoms = ase.Atoms("O%i" % len(self.oxygen_coordinates), positions=self.oxygen_coordinates, cell=self.cell, pbc = periodic)
 * 
 *         self.oxygen_coordinates += [self.x_offset, self.y_offset, self.z_offset]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__x_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__y_offset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__z_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->oxygen_coordinates), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->oxygen_coordinates);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  __pyx_v_self->oxygen_coordinates = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
 93: 
 94: 
 95:         self.symmetry_operations = []
  /* "water_algorithm_cython.pyx":95
 * 
 * 
 *         self.symmetry_operations = []             # <<<<<<<<<<<<<<
 *         self.N = len(self.oxygen_coordinates)
 *         self.store_bond_variables = store_bond_variables
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __Pyx_GOTREF(__pyx_v_self->symmetry_operations);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->symmetry_operations));
  __pyx_v_self->symmetry_operations = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
 96:         self.N = len(self.oxygen_coordinates)
  /* "water_algorithm_cython.pyx":96
 * 
 *         self.symmetry_operations = []
 *         self.N = len(self.oxygen_coordinates)             # <<<<<<<<<<<<<<
 *         self.store_bond_variables = store_bond_variables
 *         if preset_bond_values != None and type(preset_bond_values) == list:
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_7 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->N = __pyx_t_7;
 97:         self.store_bond_variables = store_bond_variables
  /* "water_algorithm_cython.pyx":97
 *         self.symmetry_operations = []
 *         self.N = len(self.oxygen_coordinates)
 *         self.store_bond_variables = store_bond_variables             # <<<<<<<<<<<<<<
 *         if preset_bond_values != None and type(preset_bond_values) == list:
 *             self.preset_bond_values = self.preset_bonds_list_to_dict(preset_bond_values)
 */
  if (!(likely(((__pyx_v_store_bond_variables) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_store_bond_variables, __pyx_ptype_7cpython_4bool_bool))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_store_bond_variables);
  __Pyx_GIVEREF(__pyx_v_store_bond_variables);
  __Pyx_GOTREF(__pyx_v_self->store_bond_variables);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->store_bond_variables));
  __pyx_v_self->store_bond_variables = ((PyBoolObject *)__pyx_v_store_bond_variables);
 98:         if preset_bond_values != None and type(preset_bond_values) == list:
  /* "water_algorithm_cython.pyx":98
 *         self.N = len(self.oxygen_coordinates)
 *         self.store_bond_variables = store_bond_variables
 *         if preset_bond_values != None and type(preset_bond_values) == list:             # <<<<<<<<<<<<<<
 *             self.preset_bond_values = self.preset_bonds_list_to_dict(preset_bond_values)
 *         else:
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_preset_bond_values, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {
    __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_preset_bond_values)), ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_t_8;
  } else {
    __pyx_t_9 = __pyx_t_2;
  }
  if (__pyx_t_9) {
 99:             self.preset_bond_values = self.preset_bonds_list_to_dict(preset_bond_values)
    /* "water_algorithm_cython.pyx":99
 *         self.store_bond_variables = store_bond_variables
 *         if preset_bond_values != None and type(preset_bond_values) == list:
 *             self.preset_bond_values = self.preset_bonds_list_to_dict(preset_bond_values)             # <<<<<<<<<<<<<<
 *         else:
 *             self.preset_bond_values = preset_bond_values
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_preset_bond_values);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_preset_bond_values);
    __Pyx_GIVEREF(__pyx_v_preset_bond_values);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L9;
  }
  /*else*/ {
 100:         else:
 101:             self.preset_bond_values = preset_bond_values
    /* "water_algorithm_cython.pyx":101
 *             self.preset_bond_values = self.preset_bonds_list_to_dict(preset_bond_values)
 *         else:
 *             self.preset_bond_values = preset_bond_values             # <<<<<<<<<<<<<<
 *         self.logfile = None
 *         self.write_geometries = False
 */
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values, __pyx_v_preset_bond_values) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L9:;
 102:         self.logfile = None
  /* "water_algorithm_cython.pyx":102
 *         else:
 *             self.preset_bond_values = preset_bond_values
 *         self.logfile = None             # <<<<<<<<<<<<<<
 *         self.write_geometries = False
 *         if type(self.periodic) == list or type(self.periodic) == np.ndarray:
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->logfile);
  __Pyx_DECREF(__pyx_v_self->logfile);
  __pyx_v_self->logfile = Py_None;
 103:         self.write_geometries = False
  /* "water_algorithm_cython.pyx":103
 *             self.preset_bond_values = preset_bond_values
 *         self.logfile = None
 *         self.write_geometries = False             # <<<<<<<<<<<<<<
 *         if type(self.periodic) == list or type(self.periodic) == np.ndarray:
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=any(self.periodic), cell=self.cell)
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->write_geometries);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->write_geometries));
  __pyx_v_self->write_geometries = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 104:         if type(self.periodic) == list or type(self.periodic) == np.ndarray:
  /* "water_algorithm_cython.pyx":104
 *         self.logfile = None
 *         self.write_geometries = False
 *         if type(self.periodic) == list or type(self.periodic) == np.ndarray:             # <<<<<<<<<<<<<<
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=any(self.periodic), cell=self.cell)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_1)), ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!__pyx_t_9) {
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_6)), ((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __pyx_t_2;
  } else {
    __pyx_t_8 = __pyx_t_9;
  }
  if (__pyx_t_8) {
 105:             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=any(self.periodic), cell=self.cell)
    /* "water_algorithm_cython.pyx":105
 *         self.write_geometries = False
 *         if type(self.periodic) == list or type(self.periodic) == np.ndarray:
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=any(self.periodic), cell=self.cell)             # <<<<<<<<<<<<<<
 *         else:
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=self.periodic, cell=self.cell)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_self->oxygen_coordinates));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_builtin_any, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__periodic), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__cell), __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L10;
  }
  /*else*/ {
 106:         else:
 107:             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=self.periodic, cell=self.cell)
    /* "water_algorithm_cython.pyx":107
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=any(self.periodic), cell=self.cell)
 *         else:
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=self.periodic, cell=self.cell)             # <<<<<<<<<<<<<<
 *         if scale:
 *             average = get_average_oxygen_distance(self.oxygen_coordinates, self.nearest_neighbors_nos)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_13); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->oxygen_coordinates));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__periodic), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__cell), __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L10:;
 108:         if scale:
  /* "water_algorithm_cython.pyx":108
 *         else:
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=self.periodic, cell=self.cell)
 *         if scale:             # <<<<<<<<<<<<<<
 *             average = get_average_oxygen_distance(self.oxygen_coordinates, self.nearest_neighbors_nos)
 *             scaling_factor = self.O_O_distance / average
 */
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_scale); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_8) {
 109:             average = get_average_oxygen_distance(self.oxygen_coordinates, self.nearest_neighbors_nos)
    /* "water_algorithm_cython.pyx":109
 *             self.nearest_neighbors_nos = all_nearest_neighbors_no(self,  self.oxygen_coordinates, periodic=self.periodic, cell=self.cell)
 *         if scale:
 *             average = get_average_oxygen_distance(self.oxygen_coordinates, self.nearest_neighbors_nos)             # <<<<<<<<<<<<<<
 *             scaling_factor = self.O_O_distance / average
 *             self.oxygen_coordinates *= scaling_factor
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->oxygen_coordinates));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_v_average = __pyx_t_6;
    __pyx_t_6 = 0;
 110:             scaling_factor = self.O_O_distance / average
    /* "water_algorithm_cython.pyx":110
 *         if scale:
 *             average = get_average_oxygen_distance(self.oxygen_coordinates, self.nearest_neighbors_nos)
 *             scaling_factor = self.O_O_distance / average             # <<<<<<<<<<<<<<
 *             self.oxygen_coordinates *= scaling_factor
 *             #print scaling_factor
 */
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->O_O_distance); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_v_average); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_scaling_factor = __pyx_t_3;
    __pyx_t_3 = 0;
 111:             self.oxygen_coordinates *= scaling_factor
    /* "water_algorithm_cython.pyx":111
 *             average = get_average_oxygen_distance(self.oxygen_coordinates, self.nearest_neighbors_nos)
 *             scaling_factor = self.O_O_distance / average
 *             self.oxygen_coordinates *= scaling_factor             # <<<<<<<<<<<<<<
 *             #print scaling_factor
 *             #if self.cell != None:
 */
    __pyx_t_3 = PyNumber_InPlaceMultiply(((PyObject *)__pyx_v_self->oxygen_coordinates), __pyx_v_scaling_factor); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->oxygen_coordinates);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    __pyx_v_self->oxygen_coordinates = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L11;
  }
  __pyx_L11:;
 112:             #print scaling_factor
 113:             #if self.cell != None:
 114:             #    self.cell *= scaling_factor
 115:         self.write_oxygen_raft_to_file()
  /* "water_algorithm_cython.pyx":115
 *             #if self.cell != None:
 *             #    self.cell *= scaling_factor
 *         self.write_oxygen_raft_to_file()             # <<<<<<<<<<<<<<
 *         if do_symmetry_check == None:
 *             self.do_symmetry_check = np.ones(len(self.oxygen_coordinates), dtype=DTYPE)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 116:         if do_symmetry_check == None:
  /* "water_algorithm_cython.pyx":116
 *             #    self.cell *= scaling_factor
 *         self.write_oxygen_raft_to_file()
 *         if do_symmetry_check == None:             # <<<<<<<<<<<<<<
 *             self.do_symmetry_check = np.ones(len(self.oxygen_coordinates), dtype=DTYPE)
 *         elif do_symmetry_check == False:
 */
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_do_symmetry_check, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_8) {
 117:             self.do_symmetry_check = np.ones(len(self.oxygen_coordinates), dtype=DTYPE)
    /* "water_algorithm_cython.pyx":117
 *         self.write_oxygen_raft_to_file()
 *         if do_symmetry_check == None:
 *             self.do_symmetry_check = np.ones(len(self.oxygen_coordinates), dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         elif do_symmetry_check == False:
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__ones); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->do_symmetry_check);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->do_symmetry_check));
    __pyx_v_self->do_symmetry_check = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L12;
  }
 118:         elif do_symmetry_check == False:
  /* "water_algorithm_cython.pyx":118
 *         if do_symmetry_check == None:
 *             self.do_symmetry_check = np.ones(len(self.oxygen_coordinates), dtype=DTYPE)
 *         elif do_symmetry_check == False:             # <<<<<<<<<<<<<<
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
 *         else:
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_do_symmetry_check, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_8) {
 119:             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
    /* "water_algorithm_cython.pyx":119
 *             self.do_symmetry_check = np.ones(len(self.oxygen_coordinates), dtype=DTYPE)
 *         elif do_symmetry_check == False:
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         else:
 *             self.do_symmetry_check = do_symmetry_check
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->do_symmetry_check);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->do_symmetry_check));
    __pyx_v_self->do_symmetry_check = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L12;
  }
  /*else*/ {
 120:         else:
 121:             self.do_symmetry_check = do_symmetry_check
    /* "water_algorithm_cython.pyx":121
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
 *         else:
 *             self.do_symmetry_check = do_symmetry_check             # <<<<<<<<<<<<<<
 *         if order == None:
 *             self.order = np.arange(0, len(self.oxygen_coordinates), 1, dtype=DTYPE)
 */
    if (!(likely(((__pyx_v_do_symmetry_check) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_do_symmetry_check, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_INCREF(__pyx_v_do_symmetry_check);
    __Pyx_GIVEREF(__pyx_v_do_symmetry_check);
    __Pyx_GOTREF(__pyx_v_self->do_symmetry_check);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->do_symmetry_check));
    __pyx_v_self->do_symmetry_check = ((PyArrayObject *)__pyx_v_do_symmetry_check);
  }
  __pyx_L12:;
 122:         if order == None:
  /* "water_algorithm_cython.pyx":122
 *         else:
 *             self.do_symmetry_check = do_symmetry_check
 *         if order == None:             # <<<<<<<<<<<<<<
 *             self.order = np.arange(0, len(self.oxygen_coordinates), 1, dtype=DTYPE)
 *         else:
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_order, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_8) {
 123:             self.order = np.arange(0, len(self.oxygen_coordinates), 1, dtype=DTYPE)
    /* "water_algorithm_cython.pyx":123
 *             self.do_symmetry_check = do_symmetry_check
 *         if order == None:
 *             self.order = np.arange(0, len(self.oxygen_coordinates), 1, dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         else:
 *             self.order = np.array(order, dtype=DTYPE)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__arange); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_7 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->order);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->order));
    __pyx_v_self->order = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L13;
  }
  /*else*/ {
 124:         else:
 125:             self.order = np.array(order, dtype=DTYPE)
    /* "water_algorithm_cython.pyx":125
 *             self.order = np.arange(0, len(self.oxygen_coordinates), 1, dtype=DTYPE)
 *         else:
 *             self.order = np.array(order, dtype=DTYPE)             # <<<<<<<<<<<<<<
 * 
 *         print self.O_O_distance
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_order);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_order);
    __Pyx_GIVEREF(__pyx_v_order);
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->order);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->order));
    __pyx_v_self->order = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
  }
  __pyx_L13:;
 126: 
 127:         print self.O_O_distance
  /* "water_algorithm_cython.pyx":127
 *             self.order = np.array(order, dtype=DTYPE)
 * 
 *         print self.O_O_distance             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->O_O_distance); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (__Pyx_PrintOne(0, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.initialize", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_average);
  __Pyx_XDECREF(__pyx_v_scaling_factor);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_5handle_periodic_input(PyObject *__pyx_v_self, PyObject *__pyx_v_periodic); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_5handle_periodic_input(PyObject *__pyx_v_self, PyObject *__pyx_v_periodic) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_periodic_input (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_4handle_periodic_input(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_periodic));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 128: 
 129: 
 130:     def handle_periodic_input(self, periodic):
/* "water_algorithm_cython.pyx":130
 * 
 * 
 *     def handle_periodic_input(self, periodic):             # <<<<<<<<<<<<<<
 *         if type(periodic) == list or type(periodic) == bool:
 *             return periodic
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_4handle_periodic_input(CYTHON_UNUSED struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_periodic) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_periodic_input", 0);
 131:         if type(periodic) == list or type(periodic) == bool:
  /* "water_algorithm_cython.pyx":131
 * 
 *     def handle_periodic_input(self, periodic):
 *         if type(periodic) == list or type(periodic) == bool:             # <<<<<<<<<<<<<<
 *             return periodic
 *         else:
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_periodic)), ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!__pyx_t_2) {
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_periodic)), ((PyObject *)((PyObject*)__pyx_ptype_7cpython_4bool_bool)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {
 132:             return periodic
    /* "water_algorithm_cython.pyx":132
 *     def handle_periodic_input(self, periodic):
 *         if type(periodic) == list or type(periodic) == bool:
 *             return periodic             # <<<<<<<<<<<<<<
 *         else:
 *             if periodic == 'x-wire':
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_periodic);
    __pyx_r = __pyx_v_periodic;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {
 133:         else:
 134:             if periodic == 'x-wire':
    /* "water_algorithm_cython.pyx":134
 *             return periodic
 *         else:
 *             if periodic == 'x-wire':             # <<<<<<<<<<<<<<
 *                 return [True, False, False]
 *             elif periodic == 'y-wire':
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_periodic, ((PyObject *)__pyx_kp_s_17), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
 135:                 return [True, False, False]
      /* "water_algorithm_cython.pyx":135
 *         else:
 *             if periodic == 'x-wire':
 *                 return [True, False, False]             # <<<<<<<<<<<<<<
 *             elif periodic == 'y-wire':
 *                 return [False, True, False]
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_r = ((PyObject *)__pyx_t_7);
      __pyx_t_7 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
 136:             elif periodic == 'y-wire':
    /* "water_algorithm_cython.pyx":136
 *             if periodic == 'x-wire':
 *                 return [True, False, False]
 *             elif periodic == 'y-wire':             # <<<<<<<<<<<<<<
 *                 return [False, True, False]
 *             elif periodic == 'z-wire':
 */
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_periodic, ((PyObject *)__pyx_kp_s_18), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_4) {
 137:                 return [False, True, False]
      /* "water_algorithm_cython.pyx":137
 *                 return [True, False, False]
 *             elif periodic == 'y-wire':
 *                 return [False, True, False]             # <<<<<<<<<<<<<<
 *             elif periodic == 'z-wire':
 *                 return [False, False, True]
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_r = ((PyObject *)__pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
 138:             elif periodic == 'z-wire':
    /* "water_algorithm_cython.pyx":138
 *             elif periodic == 'y-wire':
 *                 return [False, True, False]
 *             elif periodic == 'z-wire':             # <<<<<<<<<<<<<<
 *                 return [False, False, True]
 *             elif periodic == 'slab':
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_periodic, ((PyObject *)__pyx_kp_s_19), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
 139:                 return [False, False, True]
      /* "water_algorithm_cython.pyx":139
 *                 return [False, True, False]
 *             elif periodic == 'z-wire':
 *                 return [False, False, True]             # <<<<<<<<<<<<<<
 *             elif periodic == 'slab':
 *                 return [True, True, False]
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_1 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_r = ((PyObject *)__pyx_t_7);
      __pyx_t_7 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
 140:             elif periodic == 'slab':
    /* "water_algorithm_cython.pyx":140
 *             elif periodic == 'z-wire':
 *                 return [False, False, True]
 *             elif periodic == 'slab':             # <<<<<<<<<<<<<<
 *                 return [True, True, False]
 *             elif periodic == 'bulk':
 */
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_periodic, ((PyObject *)__pyx_n_s__slab), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_4) {
 141:                 return [True, True, False]
      /* "water_algorithm_cython.pyx":141
 *                 return [False, False, True]
 *             elif periodic == 'slab':
 *                 return [True, True, False]             # <<<<<<<<<<<<<<
 *             elif periodic == 'bulk':
 *                 return True
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_7 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_r = ((PyObject *)__pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
 142:             elif periodic == 'bulk':
    /* "water_algorithm_cython.pyx":142
 *             elif periodic == 'slab':
 *                 return [True, True, False]
 *             elif periodic == 'bulk':             # <<<<<<<<<<<<<<
 *                 return True
 *             else:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_periodic, ((PyObject *)__pyx_n_s__bulk), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_4) {
 143:                 return True
      /* "water_algorithm_cython.pyx":143
 *                 return [True, True, False]
 *             elif periodic == 'bulk':
 *                 return True             # <<<<<<<<<<<<<<
 *             else:
 *                 return False
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    /*else*/ {
 144:             else:
 145:                 return False
      /* "water_algorithm_cython.pyx":145
 *                 return True
 *             else:
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *     def load_single_result(self, number):
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __pyx_L4:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_periodic_input", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_7load_single_result(PyObject *__pyx_v_self, PyObject *__pyx_v_number); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_7load_single_result(PyObject *__pyx_v_self, PyObject *__pyx_v_number) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_single_result (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_6load_single_result(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 146: 
 147:     def load_single_result(self, number):
/* "water_algorithm_cython.pyx":147
 *                 return False
 * 
 *     def load_single_result(self, number):             # <<<<<<<<<<<<<<
 *         try:
 *             import linecache
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_6load_single_result(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_number) {
  PyObject *__pyx_v_linecache = NULL;
  PyObject *__pyx_v_line = NULL;
  PyObject *__pyx_v_words = NULL;
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_word = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_single_result", 0);
 148:         try:
  /* "water_algorithm_cython.pyx":148
 * 
 *     def load_single_result(self, number):
 *         try:             # <<<<<<<<<<<<<<
 *             import linecache
 *             line = linecache.getline(self.get_folder()+"allresults.txt", number +1)
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
 149:             import linecache
      /* "water_algorithm_cython.pyx":149
 *     def load_single_result(self, number):
 *         try:
 *             import linecache             # <<<<<<<<<<<<<<
 *             line = linecache.getline(self.get_folder()+"allresults.txt", number +1)
 *             words = line.split()
 */
      __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s__linecache), 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_v_linecache = __pyx_t_4;
      __pyx_t_4 = 0;
 150:             line = linecache.getline(self.get_folder()+"allresults.txt", number +1)
      /* "water_algorithm_cython.pyx":150
 *         try:
 *             import linecache
 *             line = linecache.getline(self.get_folder()+"allresults.txt", number +1)             # <<<<<<<<<<<<<<
 *             words = line.split()
 *             result = np.zeros(len(words), dtype=DTYPE2)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_linecache, __pyx_n_s__getline); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_20)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Add(__pyx_v_number, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __pyx_v_line = __pyx_t_6;
      __pyx_t_6 = 0;
 151:             words = line.split()
      /* "water_algorithm_cython.pyx":151
 *             import linecache
 *             line = linecache.getline(self.get_folder()+"allresults.txt", number +1)
 *             words = line.split()             # <<<<<<<<<<<<<<
 *             result = np.zeros(len(words), dtype=DTYPE2)
 *             for i, word in enumerate(words):
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_line, __pyx_n_s__split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_words = __pyx_t_7;
      __pyx_t_7 = 0;
 152:             result = np.zeros(len(words), dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":152
 *             line = linecache.getline(self.get_folder()+"allresults.txt", number +1)
 *             words = line.split()
 *             result = np.zeros(len(words), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *             for i, word in enumerate(words):
 *                 result[i] = int(word)
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = PyObject_Length(__pyx_v_words); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __pyx_v_result = __pyx_t_5;
      __pyx_t_5 = 0;
 153:             for i, word in enumerate(words):
      /* "water_algorithm_cython.pyx":153
 *             words = line.split()
 *             result = np.zeros(len(words), dtype=DTYPE2)
 *             for i, word in enumerate(words):             # <<<<<<<<<<<<<<
 *                 result[i] = int(word)
 *             return result
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_5 = __pyx_int_0;
      if (PyList_CheckExact(__pyx_v_words) || PyTuple_CheckExact(__pyx_v_words)) {
        __pyx_t_7 = __pyx_v_words; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_words); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = Py_TYPE(__pyx_t_7)->tp_iternext;
      }
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_7)) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          #endif
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_7)) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
          #endif
        } else {
          __pyx_t_4 = __pyx_t_9(__pyx_t_7);
          if (unlikely(!__pyx_t_4)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_XDECREF(__pyx_v_word);
        __pyx_v_word = __pyx_t_4;
        __pyx_t_4 = 0;
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_XDECREF(__pyx_v_i);
        __pyx_v_i = __pyx_t_5;
        __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5);
        __pyx_t_5 = __pyx_t_4;
        __pyx_t_4 = 0;
 154:                 result[i] = int(word)
        /* "water_algorithm_cython.pyx":154
 *             result = np.zeros(len(words), dtype=DTYPE2)
 *             for i, word in enumerate(words):
 *                 result[i] = int(word)             # <<<<<<<<<<<<<<
 *             return result
 *         except:
 */
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_v_word);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_word);
        __Pyx_GIVEREF(__pyx_v_word);
        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        if (PyObject_SetItem(__pyx_v_result, __pyx_v_i, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 155:             return result
      /* "water_algorithm_cython.pyx":155
 *             for i, word in enumerate(words):
 *                 result[i] = int(word)
 *             return result             # <<<<<<<<<<<<<<
 *         except:
 *             raise Exception("Failed loading result number %i" % number)
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_result);
      __pyx_r = __pyx_v_result;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
 156:         except:
    /* "water_algorithm_cython.pyx":156
 *                 result[i] = int(word)
 *             return result
 *         except:             # <<<<<<<<<<<<<<
 *             raise Exception("Failed loading result number %i" % number)
 * 
 */
    /*except:*/ {
      __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.load_single_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_6);
 157:             raise Exception("Failed loading result number %i" % number)
      /* "water_algorithm_cython.pyx":157
 *             return result
 *         except:
 *             raise Exception("Failed loading result number %i" % number)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_number); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_4));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L10_try_end:;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.load_single_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_linecache);
  __Pyx_XDECREF(__pyx_v_line);
  __Pyx_XDECREF(__pyx_v_words);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_word);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_9load_results(PyObject *__pyx_v_self, PyObject *__pyx_v_nozeros); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_8load_results[] = "\n            Numpy loading of results, DEPRECATED\n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_9load_results(PyObject *__pyx_v_self, PyObject *__pyx_v_nozeros) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_results (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_8load_results(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_nozeros));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 158: 
 159: 
 160:     def load_results(self, nozeros):
/* "water_algorithm_cython.pyx":160
 * 
 * 
 *     def load_results(self, nozeros):             # <<<<<<<<<<<<<<
 *         """
 *             Numpy loading of results, DEPRECATED
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_8load_results(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_nozeros) {
  PyObject *__pyx_v_wo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_results", 0);
 161:         """
 162:             Numpy loading of results, DEPRECATED
 163:         """
 164:         if os.path.exists(self.get_folder()+"nozero_results.txt") or os.path.exists(self.get_folder()+"allresults.txt"):
  /* "water_algorithm_cython.pyx":164
 *             Numpy loading of results, DEPRECATED
 *         """
 *         if os.path.exists(self.get_folder()+"nozero_results.txt") or os.path.exists(self.get_folder()+"allresults.txt"):             # <<<<<<<<<<<<<<
 *             try:
 *                 if nozeros:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_3, ((PyObject *)__pyx_kp_s_22)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_kp_s_20)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __pyx_t_5;
  } else {
    __pyx_t_6 = __pyx_t_4;
  }
  if (__pyx_t_6) {
 165:             try:
    /* "water_algorithm_cython.pyx":165
 *         """
 *         if os.path.exists(self.get_folder()+"nozero_results.txt") or os.path.exists(self.get_folder()+"allresults.txt"):
 *             try:             # <<<<<<<<<<<<<<
 *                 if nozeros:
 *                     wo = np.loadtxt(self.get_folder()+"nozero_results.txt",  dtype=DTYPE2)
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      /*try:*/ {
 166:                 if nozeros:
        /* "water_algorithm_cython.pyx":166
 *         if os.path.exists(self.get_folder()+"nozero_results.txt") or os.path.exists(self.get_folder()+"allresults.txt"):
 *             try:
 *                 if nozeros:             # <<<<<<<<<<<<<<
 *                     wo = np.loadtxt(self.get_folder()+"nozero_results.txt",  dtype=DTYPE2)
 *                 else:
 */
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_nozeros); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        if (__pyx_t_6) {
 167:                     wo = np.loadtxt(self.get_folder()+"nozero_results.txt",  dtype=DTYPE2)
          /* "water_algorithm_cython.pyx":167
 *             try:
 *                 if nozeros:
 *                     wo = np.loadtxt(self.get_folder()+"nozero_results.txt",  dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                 else:
 *                     wo = np.loadtxt(self.get_folder()+"allresults.txt",  dtype=DTYPE2)
 */
          __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__loadtxt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_kp_s_22)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_10);
          if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_v_wo = __pyx_t_10;
          __pyx_t_10 = 0;
          goto __pyx_L12;
        }
        /*else*/ {
 168:                 else:
 169:                     wo = np.loadtxt(self.get_folder()+"allresults.txt",  dtype=DTYPE2)
          /* "water_algorithm_cython.pyx":169
 *                     wo = np.loadtxt(self.get_folder()+"nozero_results.txt",  dtype=DTYPE2)
 *                 else:
 *                     wo = np.loadtxt(self.get_folder()+"allresults.txt",  dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *             except:
 *                 return None
 */
          __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__loadtxt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_2 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = PyNumber_Add(__pyx_t_2, ((PyObject *)__pyx_kp_s_20)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_10));
          __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
          __pyx_v_wo = __pyx_t_1;
          __pyx_t_1 = 0;
        }
        __pyx_L12:;
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 170:             except:
      /* "water_algorithm_cython.pyx":170
 *                 else:
 *                     wo = np.loadtxt(self.get_folder()+"allresults.txt",  dtype=DTYPE2)
 *             except:             # <<<<<<<<<<<<<<
 *                 return None
 *         else:
 */
      /*except:*/ {
        __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.load_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_10, &__pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GOTREF(__pyx_t_2);
 171:                 return None
        /* "water_algorithm_cython.pyx":171
 *                     wo = np.loadtxt(self.get_folder()+"allresults.txt",  dtype=DTYPE2)
 *             except:
 *                 return None             # <<<<<<<<<<<<<<
 *         else:
 *             return None
 */
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_None);
        __pyx_r = Py_None;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L7_except_return;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L5_exception_handled;
      }
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L1_error;
      __pyx_L7_except_return:;
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      goto __pyx_L0;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      __pyx_L11_try_end:;
    }
    goto __pyx_L3;
  }
  /*else*/ {
 172:         else:
 173:             return None
    /* "water_algorithm_cython.pyx":173
 *                 return None
 *         else:
 *             return None             # <<<<<<<<<<<<<<
 *         return wo
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  __pyx_L3:;
 174:         return wo
  /* "water_algorithm_cython.pyx":174
 *         else:
 *             return None
 *         return wo             # <<<<<<<<<<<<<<
 * 
 *     cdef void load_invariants(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_wo);
  __pyx_r = __pyx_v_wo;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.load_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 175: 
 176:     cdef void load_invariants(self):
/* "water_algorithm_cython.pyx":176
 *         return wo
 * 
 *     cdef void load_invariants(self):             # <<<<<<<<<<<<<<
 *         """
 *             Loads graph invariants to the graph_invariants parameter of WaterAlgorithm object (self).
 */

static void __pyx_f_22water_algorithm_cython_14WaterAlgorithm_load_invariants(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_symmetry_operations = 0;
  CYTHON_UNUSED int __pyx_v_N;
  PyObject *__pyx_v_conversion_table = 0;
  PyObject *__pyx_v_gi = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_invariants", 0);
 177:         """
 178:             Loads graph invariants to the graph_invariants parameter of WaterAlgorithm object (self).
 179:             The actual method are located at graph_invariants_cython -module.
 180:         """
 181:         cdef list symmetry_operations = self.symmetry_operations
  /* "water_algorithm_cython.pyx":181
 *             The actual method are located at graph_invariants_cython -module.
 *         """
 *         cdef list symmetry_operations = self.symmetry_operations             # <<<<<<<<<<<<<<
 *         cdef int i, N = len(symmetry_operations)
 *         cdef SymmetryOperation symmetry_operation
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->symmetry_operations);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_symmetry_operations = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 182:         cdef int i, N = len(symmetry_operations)
  /* "water_algorithm_cython.pyx":182
 *         """
 *         cdef list symmetry_operations = self.symmetry_operations
 *         cdef int i, N = len(symmetry_operations)             # <<<<<<<<<<<<<<
 *         cdef SymmetryOperation symmetry_operation
 *         cdef dict conversion_table
 */
  if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_N = __pyx_t_2;
 183:         cdef SymmetryOperation symmetry_operation
 184:         cdef dict conversion_table
 185:         cdef list gi
 186:         if self.symmetry_operations == None or len(self.symmetry_operations) <= 1:
  /* "water_algorithm_cython.pyx":186
 *         cdef dict conversion_table
 *         cdef list gi
 *         if self.symmetry_operations == None or len(self.symmetry_operations) <= 1:             # <<<<<<<<<<<<<<
 *             self.graph_invariants == None
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->symmetry_operations), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!__pyx_t_3) {
    __pyx_t_1 = ((PyObject *)__pyx_v_self->symmetry_operations);
    __Pyx_INCREF(__pyx_t_1);
    if (unlikely(__pyx_t_1 == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = (__pyx_t_2 <= 1);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_3;
  }
  if (__pyx_t_5) {
 187:             self.graph_invariants == None
    /* "water_algorithm_cython.pyx":187
 *         cdef list gi
 *         if self.symmetry_operations == None or len(self.symmetry_operations) <= 1:
 *             self.graph_invariants == None             # <<<<<<<<<<<<<<
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
 *         if rank == 0:
 */
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->graph_invariants), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 188:             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
    /* "water_algorithm_cython.pyx":188
 *         if self.symmetry_operations == None or len(self.symmetry_operations) <= 1:
 *             self.graph_invariants == None
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         if rank == 0:
 *             #for i from 0 <= i < N:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_8);
    __Pyx_GOTREF(__pyx_v_self->do_symmetry_check);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->do_symmetry_check));
    __pyx_v_self->do_symmetry_check = ((PyArrayObject *)__pyx_t_8);
    __pyx_t_8 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 189:         if rank == 0:
  /* "water_algorithm_cython.pyx":189
 *             self.graph_invariants == None
 *             self.do_symmetry_check = np.zeros(len(self.oxygen_coordinates), dtype=DTYPE)
 *         if rank == 0:             # <<<<<<<<<<<<<<
 *             #for i from 0 <= i < N:
 *             #    symmetry_operation = symmetry_operations[i]
 */
  __pyx_t_5 = (rank == 0);
  if (__pyx_t_5) {
 190:             #for i from 0 <= i < N:
 191:             #    symmetry_operation = symmetry_operations[i]
 192:             #    symmetry_operation.get_symbolic_bond_variable_matrix(self.nearest_neighbors_nos, self)
 193:             #print self.get_folder()
 194:             gi = get_invariants(self.symmetry_operations,  self.nearest_neighbors_nos, True, False, self.get_folder(), False, self, self.invariant_count)
    /* "water_algorithm_cython.pyx":194
 *             #    symmetry_operation.get_symbolic_bond_variable_matrix(self.nearest_neighbors_nos, self)
 *             #print self.get_folder()
 *             gi = get_invariants(self.symmetry_operations,  self.nearest_neighbors_nos, True, False, self.get_folder(), False, self, self.invariant_count)             # <<<<<<<<<<<<<<
 * 
 *             if len(gi) > self.invariant_count:
 */
    __pyx_t_8 = ((PyObject *)__pyx_v_self->symmetry_operations);
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (!(likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__invariant_count); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_11); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __pyx_f_23graph_invariants_cython_get_invariants(((PyObject*)__pyx_t_8), ((PyArrayObject *)__pyx_t_1), ((PyBoolObject *)__pyx_t_7), ((PyBoolObject *)__pyx_t_6), __pyx_t_10, ((PyBoolObject *)__pyx_t_9), __pyx_v_self, __pyx_t_12); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_11))||((__pyx_t_11) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_11)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_gi = ((PyObject*)__pyx_t_11);
    __pyx_t_11 = 0;
 195: 
 196:             if len(gi) > self.invariant_count:
    /* "water_algorithm_cython.pyx":196
 *             gi = get_invariants(self.symmetry_operations,  self.nearest_neighbors_nos, True, False, self.get_folder(), False, self, self.invariant_count)
 * 
 *             if len(gi) > self.invariant_count:             # <<<<<<<<<<<<<<
 *                 gi = gi[:self.invariant_count]
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_gi) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_gi)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__invariant_count); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyObject_RichCompare(__pyx_t_11, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_5) {
 197:                 gi = gi[:self.invariant_count]
      /* "water_algorithm_cython.pyx":197
 * 
 *             if len(gi) > self.invariant_count:
 *                 gi = gi[:self.invariant_count]             # <<<<<<<<<<<<<<
 * 
 *             conversion_table = get_index_conversion_table(self.nearest_neighbors_nos)
 */
      if (unlikely(((PyObject *)__pyx_v_gi) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__invariant_count); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_10); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = __Pyx_PyList_GetSlice(((PyObject *)__pyx_v_gi), 0, __pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_10));
      __Pyx_DECREF(((PyObject *)__pyx_v_gi));
      __pyx_v_gi = ((PyObject*)__pyx_t_10);
      __pyx_t_10 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
 198: 
 199:             conversion_table = get_index_conversion_table(self.nearest_neighbors_nos)
    /* "water_algorithm_cython.pyx":199
 *                 gi = gi[:self.invariant_count]
 * 
 *             conversion_table = get_index_conversion_table(self.nearest_neighbors_nos)             # <<<<<<<<<<<<<<
 *             initialize_new_indexing(conversion_table, gi)
 *         else:
 */
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyObject *)__pyx_f_22water_algorithm_cython_get_index_conversion_table(((PyArrayObject *)__pyx_t_10))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_v_conversion_table = ((PyObject*)__pyx_t_9);
    __pyx_t_9 = 0;
 200:             initialize_new_indexing(conversion_table, gi)
    /* "water_algorithm_cython.pyx":200
 * 
 *             conversion_table = get_index_conversion_table(self.nearest_neighbors_nos)
 *             initialize_new_indexing(conversion_table, gi)             # <<<<<<<<<<<<<<
 *         else:
 *             gi = None
 */
    __pyx_f_23graph_invariants_cython_initialize_new_indexing(__pyx_v_conversion_table, __pyx_v_gi);
    goto __pyx_L4;
  }
  /*else*/ {
 201:         else:
 202:             gi = None
    /* "water_algorithm_cython.pyx":202
 *             initialize_new_indexing(conversion_table, gi)
 *         else:
 *             gi = None             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_gi = ((PyObject*)Py_None);
  }
  __pyx_L4:;
 203: 
 204: 
 205:         if size != 1:
  /* "water_algorithm_cython.pyx":205
 * 
 * 
 *         if size != 1:             # <<<<<<<<<<<<<<
 *             #print "GERE, %i" % len(gi)
 * 
 */
  __pyx_t_5 = (size != 1);
  if (__pyx_t_5) {
 206:             #print "GERE, %i" % len(gi)
 207: 
 208:             self.graph_invariants = comm.bcast(gi,  root=0)
    /* "water_algorithm_cython.pyx":208
 *             #print "GERE, %i" % len(gi)
 * 
 *             self.graph_invariants = comm.bcast(gi,  root=0)             # <<<<<<<<<<<<<<
 *             #print_invariants(self.graph_invariants)
 *         else:
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(((PyObject *)__pyx_v_gi));
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_gi));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_gi));
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_11));
    if (PyDict_SetItem(__pyx_t_11, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_10), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->graph_invariants);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->graph_invariants));
    __pyx_v_self->graph_invariants = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L6;
  }
  /*else*/ {
 209:             #print_invariants(self.graph_invariants)
 210:         else:
 211:             self.graph_invariants = gi
    /* "water_algorithm_cython.pyx":211
 *             #print_invariants(self.graph_invariants)
 *         else:
 *             self.graph_invariants = gi             # <<<<<<<<<<<<<<
 *         #wos = self.load_results(False)
 *         #for wo in wos:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_gi));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_gi));
    __Pyx_GOTREF(__pyx_v_self->graph_invariants);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->graph_invariants));
    __pyx_v_self->graph_invariants = __pyx_v_gi;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_WriteUnraisable("water_algorithm_cython.WaterAlgorithm.load_invariants", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_symmetry_operations);
  __Pyx_XDECREF(__pyx_v_conversion_table);
  __Pyx_XDECREF(__pyx_v_gi);
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_11run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_10run[] = "\n            Runs the water algorithm by initializing symmetry operations, invariants and finally\n            calling the main method 'perform_2' \n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_11run(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_i = 0;
  PyObject *__pyx_v_invariant_level = 0;
  PyObject *__pyx_v_group = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i,&__pyx_n_s__invariant_level,&__pyx_n_s__group,0};
    PyObject* values[3] = {0,0,0};
 212:         #wos = self.load_results(False)
 213:         #for wo in wos:
 214:         #    self.verify_invariants(wo)
 215: 
 216:     def run(self, i=None, invariant_level=0,  group=-1):
    /* "water_algorithm_cython.pyx":216
 *         #    self.verify_invariants(wo)
 * 
 *     def run(self, i=None, invariant_level=0,  group=-1):             # <<<<<<<<<<<<<<
 *         """
 *             Runs the water algorithm by initializing symmetry operations, invariants and finally
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)__pyx_int_0);
    values[2] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__invariant_level);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "run") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_i = values[0];
    __pyx_v_invariant_level = values[1];
    __pyx_v_group = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("run", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_10run(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_i, __pyx_v_invariant_level, __pyx_v_group);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_10run(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_invariant_level, PyObject *__pyx_v_group) {
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_wator = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("run", 0);
  __Pyx_INCREF(__pyx_v_i);
 217:         """
 218:             Runs the water algorithm by initializing symmetry operations, invariants and finally
 219:             calling the main method 'perform_2'
 220:         """
 221:         s = time()
  /* "water_algorithm_cython.pyx":221
 *             calling the main method 'perform_2'
 *         """
 *         s = time()             # <<<<<<<<<<<<<<
 *         if 1 in self.do_symmetry_check:
 *             self.initialize_symmetry_operations()
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_s = __pyx_t_2;
  __pyx_t_2 = 0;
 222:         if 1 in self.do_symmetry_check:
  /* "water_algorithm_cython.pyx":222
 *         """
 *         s = time()
 *         if 1 in self.do_symmetry_check:             # <<<<<<<<<<<<<<
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 */
  __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_int_1, ((PyObject *)__pyx_v_self->do_symmetry_check), Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {
 223:             self.initialize_symmetry_operations()
    /* "water_algorithm_cython.pyx":223
 *         s = time()
 *         if 1 in self.do_symmetry_check:
 *             self.initialize_symmetry_operations()             # <<<<<<<<<<<<<<
 *             self.load_invariants()
 *         wator = np.zeros((0, self.N), dtype=np.int8)
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->initialize_symmetry_operations(__pyx_v_self);
 224:             self.load_invariants()
    /* "water_algorithm_cython.pyx":224
 *         if 1 in self.do_symmetry_check:
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()             # <<<<<<<<<<<<<<
 *         wator = np.zeros((0, self.N), dtype=np.int8)
 *         if i == None:
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->load_invariants(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;
 225:         wator = np.zeros((0, self.N), dtype=np.int8)
  /* "water_algorithm_cython.pyx":225
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 *         wator = np.zeros((0, self.N), dtype=np.int8)             # <<<<<<<<<<<<<<
 *         if i == None:
 *             i = self.order[0]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__int8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_wator = __pyx_t_6;
  __pyx_t_6 = 0;
 226:         if i == None:
  /* "water_algorithm_cython.pyx":226
 *             self.load_invariants()
 *         wator = np.zeros((0, self.N), dtype=np.int8)
 *         if i == None:             # <<<<<<<<<<<<<<
 *             i = self.order[0]
 *         self.perform_2(wator, i, self.order, self.do_symmetry_check, group, invariant_level, [])
 */
  __pyx_t_6 = PyObject_RichCompare(__pyx_v_i, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {
 227:             i = self.order[0]
    /* "water_algorithm_cython.pyx":227
 *         wator = np.zeros((0, self.N), dtype=np.int8)
 *         if i == None:
 *             i = self.order[0]             # <<<<<<<<<<<<<<
 *         self.perform_2(wator, i, self.order, self.do_symmetry_check, group, invariant_level, [])
 *         print_parallel("Execution was successful", self.logfile)
 */
    __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->order), 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_6;
    __pyx_t_6 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;
 228:         self.perform_2(wator, i, self.order, self.do_symmetry_check, group, invariant_level, [])
  /* "water_algorithm_cython.pyx":228
 *         if i == None:
 *             i = self.order[0]
 *         self.perform_2(wator, i, self.order, self.do_symmetry_check, group, invariant_level, [])             # <<<<<<<<<<<<<<
 *         print_parallel("Execution was successful", self.logfile)
 *         print_parallel("Total time used in execution %f s" % (time() - s), self.logfile)
 */
  if (!(likely(((__pyx_v_wator) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_wator, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = __Pyx_PyInt_AsUnsignedChar(__pyx_v_i); if (unlikely((__pyx_t_7 == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyObject *)__pyx_v_self->order);
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_4 = ((PyObject *)__pyx_v_self->do_symmetry_check);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_PyInt_AsSignedChar(__pyx_v_group); if (unlikely((__pyx_t_8 == (signed char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyInt_AsSignedChar(__pyx_v_invariant_level); if (unlikely((__pyx_t_9 == (signed char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->perform_2(__pyx_v_self, ((PyArrayObject *)__pyx_v_wator), __pyx_t_7, ((PyArrayObject *)__pyx_t_6), ((PyArrayObject *)__pyx_t_4), __pyx_t_8, __pyx_t_9, ((PyObject*)__pyx_t_2))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 229:         print_parallel("Execution was successful", self.logfile)
  /* "water_algorithm_cython.pyx":229
 *             i = self.order[0]
 *         self.perform_2(wator, i, self.order, self.do_symmetry_check, group, invariant_level, [])
 *         print_parallel("Execution was successful", self.logfile)             # <<<<<<<<<<<<<<
 *         print_parallel("Total time used in execution %f s" % (time() - s), self.logfile)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_23));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
  __Pyx_INCREF(__pyx_v_self->logfile);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
  __Pyx_GIVEREF(__pyx_v_self->logfile);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 230:         print_parallel("Total time used in execution %f s" % (time() - s), self.logfile)
  /* "water_algorithm_cython.pyx":230
 *         self.perform_2(wator, i, self.order, self.do_symmetry_check, group, invariant_level, [])
 *         print_parallel("Execution was successful", self.logfile)
 *         print_parallel("Total time used in execution %f s" % (time() - s), self.logfile)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_self->logfile);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
  __Pyx_GIVEREF(__pyx_v_self->logfile);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.run", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_wator);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 231: 
 232: 
 233:     cdef void initialize_symmetry_operations(self):
/* "water_algorithm_cython.pyx":233
 * 
 * 
 *     cdef void initialize_symmetry_operations(self):             # <<<<<<<<<<<<<<
 *         """
 *             Calls the initialization of symmetry operations made by interface_cython module
 */

static void __pyx_f_22water_algorithm_cython_14WaterAlgorithm_initialize_symmetry_operations(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_so = 0;
  PyObject *__pyx_v_primitive_symmetry_operations = 0;
  PyObject *__pyx_v_translation_operations = 0;
  float __pyx_v_error_tolerance;
  CYTHON_UNUSED PyBoolObject *__pyx_v_debug = 0;
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_v_s = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize_symmetry_operations", 0);
 234:         """
 235:             Calls the initialization of symmetry operations made by interface_cython module
 236:             and sets the symmetry operations to the symmetry_operations attribute of WaterAlgorithm object (self)
 237:         """
 238:         cdef list so, primitive_symmetry_operations, translation_operations
 239:         cdef float error_tolerance = 0.000005
  /* "water_algorithm_cython.pyx":239
 *         """
 *         cdef list so, primitive_symmetry_operations, translation_operations
 *         cdef float error_tolerance = 0.000005             # <<<<<<<<<<<<<<
 *         cdef bool debug = False
 *         cdef SymmetryOperation sop
 */
  __pyx_v_error_tolerance = 0.000005;
 240:         cdef bool debug = False
  /* "water_algorithm_cython.pyx":240
 *         cdef list so, primitive_symmetry_operations, translation_operations
 *         cdef float error_tolerance = 0.000005
 *         cdef bool debug = False             # <<<<<<<<<<<<<<
 *         cdef SymmetryOperation sop
 *         if rank == 0:
 */
  __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_debug = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 241:         cdef SymmetryOperation sop
 242:         if rank == 0:
  /* "water_algorithm_cython.pyx":242
 *         cdef bool debug = False
 *         cdef SymmetryOperation sop
 *         if rank == 0:             # <<<<<<<<<<<<<<
 *             oxygens = get_oxygens(self.oxygen_coordinates, periodic = self.periodic, slab = self.slab, cell = self.cell)
 *             s = time()
 */
  __pyx_t_2 = (rank == 0);
  if (__pyx_t_2) {
 243:             oxygens = get_oxygens(self.oxygen_coordinates, periodic = self.periodic, slab = self.slab, cell = self.cell)
    /* "water_algorithm_cython.pyx":243
 *         cdef SymmetryOperation sop
 *         if rank == 0:
 *             oxygens = get_oxygens(self.oxygen_coordinates, periodic = self.periodic, slab = self.slab, cell = self.cell)             # <<<<<<<<<<<<<<
 *             s = time()
 *             print "Heeere"
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_oxygens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->oxygen_coordinates));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__periodic), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__slab); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__slab), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__cell), __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_v_oxygens = __pyx_t_5;
    __pyx_t_5 = 0;
 244:             s = time()
    /* "water_algorithm_cython.pyx":244
 *         if rank == 0:
 *             oxygens = get_oxygens(self.oxygen_coordinates, periodic = self.periodic, slab = self.slab, cell = self.cell)
 *             s = time()             # <<<<<<<<<<<<<<
 *             print "Heeere"
 *             so, primitive_symmetry_operations, translation_operations = find_symmetry_operations(oxygens, error_tolerance)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_s = __pyx_t_4;
    __pyx_t_4 = 0;
 245:             print "Heeere"
    /* "water_algorithm_cython.pyx":245
 *             oxygens = get_oxygens(self.oxygen_coordinates, periodic = self.periodic, slab = self.slab, cell = self.cell)
 *             s = time()
 *             print "Heeere"             # <<<<<<<<<<<<<<
 *             so, primitive_symmetry_operations, translation_operations = find_symmetry_operations(oxygens, error_tolerance)
 *             print "Time used in symmetry operation loading %f" % (time() - s)
 */
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_n_s__Heeere)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 246:             so, primitive_symmetry_operations, translation_operations = find_symmetry_operations(oxygens, error_tolerance)
    /* "water_algorithm_cython.pyx":246
 *             s = time()
 *             print "Heeere"
 *             so, primitive_symmetry_operations, translation_operations = find_symmetry_operations(oxygens, error_tolerance)             # <<<<<<<<<<<<<<
 *             print "Time used in symmetry operation loading %f" % (time() - s)
 *             print "Found %i symmetry operations" % len(so)
 */
    __pyx_t_4 = ((PyObject *)__pyx_f_10symmetries_16interface_cython_find_symmetry_operations(__pyx_v_oxygens, __pyx_v_error_tolerance)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (likely(PyTuple_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else if (1) {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 2; __pyx_t_1 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = NULL;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_so = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_primitive_symmetry_operations = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_translation_operations = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
 247:             print "Time used in symmetry operation loading %f" % (time() - s)
    /* "water_algorithm_cython.pyx":247
 *             print "Heeere"
 *             so, primitive_symmetry_operations, translation_operations = find_symmetry_operations(oxygens, error_tolerance)
 *             print "Time used in symmetry operation loading %f" % (time() - s)             # <<<<<<<<<<<<<<
 *             print "Found %i symmetry operations" % len(so)
 *             #so = remove_equals(so, debug)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_v_s); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_25), __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 248:             print "Found %i symmetry operations" % len(so)
    /* "water_algorithm_cython.pyx":248
 *             so, primitive_symmetry_operations, translation_operations = find_symmetry_operations(oxygens, error_tolerance)
 *             print "Time used in symmetry operation loading %f" % (time() - s)
 *             print "Found %i symmetry operations" % len(so)             # <<<<<<<<<<<<<<
 *             #so = remove_equals(so, debug)
 *         else:
 */
    if (unlikely(((PyObject *)__pyx_v_so) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = PyList_GET_SIZE(((PyObject *)__pyx_v_so)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 249:             #so = remove_equals(so, debug)
 250:         else:
 251:             so = Noner
    /* "water_algorithm_cython.pyx":251
 *             #so = remove_equals(so, debug)
 *         else:
 *             so = Noner             # <<<<<<<<<<<<<<
 *             primitive_symmetry_operations = None
 *             translation_operations = None
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__Noner); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_so = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 252:             primitive_symmetry_operations = None
    /* "water_algorithm_cython.pyx":252
 *         else:
 *             so = Noner
 *             primitive_symmetry_operations = None             # <<<<<<<<<<<<<<
 *             translation_operations = None
 *         if size > 1:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_primitive_symmetry_operations = ((PyObject*)Py_None);
 253:             translation_operations = None
    /* "water_algorithm_cython.pyx":253
 *             so = Noner
 *             primitive_symmetry_operations = None
 *             translation_operations = None             # <<<<<<<<<<<<<<
 *         if size > 1:
 *             self.symmetry_operations = comm.bcast(so,  root=0)
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_translation_operations = ((PyObject*)Py_None);
  }
  __pyx_L3:;
 254:         if size > 1:
  /* "water_algorithm_cython.pyx":254
 *             primitive_symmetry_operations = None
 *             translation_operations = None
 *         if size > 1:             # <<<<<<<<<<<<<<
 *             self.symmetry_operations = comm.bcast(so,  root=0)
 *             self.primitive_symmetry_operations = comm.bcast(primitive_symmetry_operations,  root=0)
 */
  __pyx_t_2 = (size > 1);
  if (__pyx_t_2) {
 255:             self.symmetry_operations = comm.bcast(so,  root=0)
    /* "water_algorithm_cython.pyx":255
 *             translation_operations = None
 *         if size > 1:
 *             self.symmetry_operations = comm.bcast(so,  root=0)             # <<<<<<<<<<<<<<
 *             self.primitive_symmetry_operations = comm.bcast(primitive_symmetry_operations,  root=0)
 *             self.translation_operations = comm.bcast(translation_operations,  root=0)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_so));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_so));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_so));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->symmetry_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->symmetry_operations));
    __pyx_v_self->symmetry_operations = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
 256:             self.primitive_symmetry_operations = comm.bcast(primitive_symmetry_operations,  root=0)
    /* "water_algorithm_cython.pyx":256
 *         if size > 1:
 *             self.symmetry_operations = comm.bcast(so,  root=0)
 *             self.primitive_symmetry_operations = comm.bcast(primitive_symmetry_operations,  root=0)             # <<<<<<<<<<<<<<
 *             self.translation_operations = comm.bcast(translation_operations,  root=0)
 *         else:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_primitive_symmetry_operations));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_primitive_symmetry_operations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_primitive_symmetry_operations));
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->primitive_symmetry_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->primitive_symmetry_operations));
    __pyx_v_self->primitive_symmetry_operations = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 257:             self.translation_operations = comm.bcast(translation_operations,  root=0)
    /* "water_algorithm_cython.pyx":257
 *             self.symmetry_operations = comm.bcast(so,  root=0)
 *             self.primitive_symmetry_operations = comm.bcast(primitive_symmetry_operations,  root=0)
 *             self.translation_operations = comm.bcast(translation_operations,  root=0)             # <<<<<<<<<<<<<<
 *         else:
 *             self.symmetry_operations = so
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_translation_operations));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_translation_operations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_translation_operations));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->translation_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->translation_operations));
    __pyx_v_self->translation_operations = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L6;
  }
  /*else*/ {
 258:         else:
 259:             self.symmetry_operations = so
    /* "water_algorithm_cython.pyx":259
 *             self.translation_operations = comm.bcast(translation_operations,  root=0)
 *         else:
 *             self.symmetry_operations = so             # <<<<<<<<<<<<<<
 *             self.primitive_symmetry_operations = primitive_symmetry_operations
 *             self.translation_operations = translation_operations
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_so));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_so));
    __Pyx_GOTREF(__pyx_v_self->symmetry_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->symmetry_operations));
    __pyx_v_self->symmetry_operations = __pyx_v_so;
 260:             self.primitive_symmetry_operations = primitive_symmetry_operations
    /* "water_algorithm_cython.pyx":260
 *         else:
 *             self.symmetry_operations = so
 *             self.primitive_symmetry_operations = primitive_symmetry_operations             # <<<<<<<<<<<<<<
 *             self.translation_operations = translation_operations
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_primitive_symmetry_operations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_primitive_symmetry_operations));
    __Pyx_GOTREF(__pyx_v_self->primitive_symmetry_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->primitive_symmetry_operations));
    __pyx_v_self->primitive_symmetry_operations = __pyx_v_primitive_symmetry_operations;
 261:             self.translation_operations = translation_operations
    /* "water_algorithm_cython.pyx":261
 *             self.symmetry_operations = so
 *             self.primitive_symmetry_operations = primitive_symmetry_operations
 *             self.translation_operations = translation_operations             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] get_symmetries(self, np.ndarray[DTYPE2_t, ndim=1] result, np.ndarray[DTYPE_t, ndim=3] neareast_neighbors_nos, list symmetry_operations):
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_translation_operations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_translation_operations));
    __Pyx_GOTREF(__pyx_v_self->translation_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->translation_operations));
    __pyx_v_self->translation_operations = __pyx_v_translation_operations;
  }
  __pyx_L6:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("water_algorithm_cython.WaterAlgorithm.initialize_symmetry_operations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_so);
  __Pyx_XDECREF(__pyx_v_primitive_symmetry_operations);
  __Pyx_XDECREF(__pyx_v_translation_operations);
  __Pyx_XDECREF((PyObject *)__pyx_v_debug);
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_RefNannyFinishContext();
}
 262: 
 263:     cdef np.ndarray[DTYPE2_t, ndim=2] get_symmetries(self, np.ndarray[DTYPE2_t, ndim=1] result, np.ndarray[DTYPE_t, ndim=3] neareast_neighbors_nos, list symmetry_operations):
/* "water_algorithm_cython.pyx":263
 *             self.translation_operations = translation_operations
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] get_symmetries(self, np.ndarray[DTYPE2_t, ndim=1] result, np.ndarray[DTYPE_t, ndim=3] neareast_neighbors_nos, list symmetry_operations):             # <<<<<<<<<<<<<<
 *         """
 *             DEPRECATED!
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_get_symmetries(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyArrayObject *__pyx_v_result, PyArrayObject *__pyx_v_neareast_neighbors_nos, PyObject *__pyx_v_symmetry_operations) {
  PyArrayObject *__pyx_v_symmetries = 0;
  PyArrayObject *__pyx_v_symmetry = 0;
  struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *__pyx_v_symmetry_operation = 0;
  int __pyx_v_i;
  int __pyx_v_N;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_neareast_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_neareast_neighbors_nos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_symmetries;
  __Pyx_Buffer __pyx_pybuffer_symmetries;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_symmetry;
  __Pyx_Buffer __pyx_pybuffer_symmetry;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_symmetries", 0);
  __pyx_pybuffer_symmetries.pybuffer.buf = NULL;
  __pyx_pybuffer_symmetries.refcount = 0;
  __pyx_pybuffernd_symmetries.data = NULL;
  __pyx_pybuffernd_symmetries.rcbuffer = &__pyx_pybuffer_symmetries;
  __pyx_pybuffer_symmetry.pybuffer.buf = NULL;
  __pyx_pybuffer_symmetry.refcount = 0;
  __pyx_pybuffernd_symmetry.data = NULL;
  __pyx_pybuffernd_symmetry.rcbuffer = &__pyx_pybuffer_symmetry;
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
  __pyx_pybuffer_neareast_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_neareast_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_neareast_neighbors_nos.data = NULL;
  __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer = &__pyx_pybuffer_neareast_neighbors_nos;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_v_neareast_neighbors_nos, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_neareast_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_neareast_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_neareast_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_neareast_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_neareast_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_neareast_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer.shape[2];
 264:         """
 265:             DEPRECATED!
 266:             Loads the symmetries of given water orientations (result)
 267:             Parameters:
 268:                 result               : the water orientations of the given result
 269:                 nearest_neighbors_nos: the nearest neighbor nos of all water molecules
 270:                 symmetry_operations  : the SymmetryOperation objects in a python list
 271:             Returns the symmetries in a two dimensional numpy array
 272: 
 273:         """
 274:         cdef np.ndarray[DTYPE2_t, ndim=2] symmetries = np.zeros((len(symmetry_operations), result.shape[0]), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":274
 * 
 *         """
 *         cdef np.ndarray[DTYPE2_t, ndim=2] symmetries = np.zeros((len(symmetry_operations), result.shape[0]), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE2_t, ndim=1] symmetry
 *         cdef SymmetryOperation symmetry_operation
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_result->dimensions[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_symmetries.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_symmetries = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_symmetries.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_symmetries.diminfo[0].strides = __pyx_pybuffernd_symmetries.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_symmetries.diminfo[0].shape = __pyx_pybuffernd_symmetries.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_symmetries.diminfo[1].strides = __pyx_pybuffernd_symmetries.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_symmetries.diminfo[1].shape = __pyx_pybuffernd_symmetries.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_symmetries = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 275:         cdef np.ndarray[DTYPE2_t, ndim=1] symmetry
 276:         cdef SymmetryOperation symmetry_operation
 277:         cdef int i, N = len(symmetry_operations)
  /* "water_algorithm_cython.pyx":277
 *         cdef np.ndarray[DTYPE2_t, ndim=1] symmetry
 *         cdef SymmetryOperation symmetry_operation
 *         cdef int i, N = len(symmetry_operations)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < N:
 *             symmetry_operation = symmetry_operations[i]
 */
  if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_N = __pyx_t_3;
 278:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":278
 *         cdef SymmetryOperation symmetry_operation
 *         cdef int i, N = len(symmetry_operations)
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             symmetry_operation = symmetry_operations[i]
 *             symmetry = symmetry_operation.apply(result,  self, neareast_neighbors_nos, False)
 */
  __pyx_t_7 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 279:             symmetry_operation = symmetry_operations[i]
    /* "water_algorithm_cython.pyx":279
 *         cdef int i, N = len(symmetry_operations)
 *         for i from 0 <= i < N:
 *             symmetry_operation = symmetry_operations[i]             # <<<<<<<<<<<<<<
 *             symmetry = symmetry_operation.apply(result,  self, neareast_neighbors_nos, False)
 *             symmetries[i] = symmetry
 */
    if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_i)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_i), __pyx_ptype_10symmetries_25symmetry_operation_cython_SymmetryOperation))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_i);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry_operation));
    __pyx_v_symmetry_operation = ((struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_t_1);
    __pyx_t_1 = 0;
 280:             symmetry = symmetry_operation.apply(result,  self, neareast_neighbors_nos, False)
    /* "water_algorithm_cython.pyx":280
 *         for i from 0 <= i < N:
 *             symmetry_operation = symmetry_operations[i]
 *             symmetry = symmetry_operation.apply(result,  self, neareast_neighbors_nos, False)             # <<<<<<<<<<<<<<
 *             symmetries[i] = symmetry
 *             #if symmetry is not None:
 */
    __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE2_t(((PyObject *)__pyx_v_result));
    if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE_t(((PyObject *)__pyx_v_neareast_neighbors_nos));
    if (unlikely(!__pyx_t_9.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_v_symmetry_operation->__pyx_vtab)->apply(__pyx_v_symmetry_operation, __pyx_t_8, __pyx_v_self, __pyx_t_9, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer, (PyObject*)__pyx_v_symmetry, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
      }
      __pyx_pybuffernd_symmetry.diminfo[0].strides = __pyx_pybuffernd_symmetry.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_symmetry.diminfo[0].shape = __pyx_pybuffernd_symmetry.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry));
    __pyx_v_symmetry = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
 281:             symmetries[i] = symmetry
    /* "water_algorithm_cython.pyx":281
 *             symmetry_operation = symmetry_operations[i]
 *             symmetry = symmetry_operation.apply(result,  self, neareast_neighbors_nos, False)
 *             symmetries[i] = symmetry             # <<<<<<<<<<<<<<
 *             #if symmetry is not None:
 *             #    symmetries = np.vstack((symmetries,  symmetry))
 */
    if (__Pyx_SetItemInt(((PyObject *)__pyx_v_symmetries), __pyx_v_i, ((PyObject *)__pyx_v_symmetry), sizeof(int), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
 282:             #if symmetry is not None:
 283:             #    symmetries = np.vstack((symmetries,  symmetry))
 284:             #    #symmetrynames.append(symmetry_operation.name)
 285: 
 286:         #print "Symmetries count %i" % len(symmetries)
 287:         return symmetries
  /* "water_algorithm_cython.pyx":287
 * 
 *         #print "Symmetries count %i" % len(symmetries)
 *         return symmetries             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_symmetries));
  __pyx_r = ((PyArrayObject *)__pyx_v_symmetries);
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetries.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_symmetries", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_neareast_neighbors_nos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetries.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetries);
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry);
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry_operation);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_13get_hydrogen_coordinates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_13get_hydrogen_coordinates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_oxygen_positions = 0;
  PyObject *__pyx_v_water_orientations = 0;
  PyArrayObject *__pyx_v_nearest_neighbors_nos = 0;
  CYTHON_UNUSED PyObject *__pyx_v_symmetry_operation = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_hydrogen_coordinates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__oxygen_positions,&__pyx_n_s__water_orientations,&__pyx_n_s_14,&__pyx_n_s__symmetry_operation,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_0);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__oxygen_positions)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_hydrogen_coordinates", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_14)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_hydrogen_coordinates", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__symmetry_operation);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_hydrogen_coordinates") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_oxygen_positions = values[0];
    __pyx_v_water_orientations = values[1];
    __pyx_v_nearest_neighbors_nos = ((PyArrayObject *)values[2]);
    __pyx_v_symmetry_operation = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_hydrogen_coordinates", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_hydrogen_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_nearest_neighbors_nos), __pyx_ptype_5numpy_ndarray, 1, "nearest_neighbors_nos", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_12get_hydrogen_coordinates(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_oxygen_positions, __pyx_v_water_orientations, __pyx_v_nearest_neighbors_nos, __pyx_v_symmetry_operation);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 288: 
 289: 
 290: 
 291:     def get_hydrogen_coordinates(self, oxygen_positions, water_orientations, np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos,  symmetry_operation=0):
/* "water_algorithm_cython.pyx":291
 * 
 * 
 *     def get_hydrogen_coordinates(self, oxygen_positions, water_orientations, np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos,  symmetry_operation=0):             # <<<<<<<<<<<<<<
 *         result = np.zeros((0, 3))
 *         site = 1
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_12get_hydrogen_coordinates(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_oxygen_positions, PyObject *__pyx_v_water_orientations, PyArrayObject *__pyx_v_nearest_neighbors_nos, CYTHON_UNUSED PyObject *__pyx_v_symmetry_operation) {
  PyObject *__pyx_v_result = NULL;
  long __pyx_v_site;
  PyObject *__pyx_v_i = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nearest_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_nearest_neighbors_nos;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_hydrogen_coordinates", 0);
  __pyx_pybuffer_nearest_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_nearest_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_nearest_neighbors_nos.data = NULL;
  __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer = &__pyx_pybuffer_nearest_neighbors_nos;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_v_nearest_neighbors_nos, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[2];
 292:         result = np.zeros((0, 3))
  /* "water_algorithm_cython.pyx":292
 * 
 *     def get_hydrogen_coordinates(self, oxygen_positions, water_orientations, np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos,  symmetry_operation=0):
 *         result = np.zeros((0, 3))             # <<<<<<<<<<<<<<
 *         site = 1
 *         for i in range(len(oxygen_positions)):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "water_algorithm_cython.pyx":292
 * 
 *     def get_hydrogen_coordinates(self, oxygen_positions, water_orientations, np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos,  symmetry_operation=0):
 *         result = np.zeros((0, 3))             # <<<<<<<<<<<<<<
 *         site = 1
 *         for i in range(len(oxygen_positions)):
 */
  __pyx_k_tuple_27 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_3); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_27);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27));
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_28), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_k_tuple_28 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_27)); if (unlikely(!__pyx_k_tuple_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_28);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_28));
 293:         site = 1
  /* "water_algorithm_cython.pyx":293
 *     def get_hydrogen_coordinates(self, oxygen_positions, water_orientations, np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos,  symmetry_operation=0):
 *         result = np.zeros((0, 3))
 *         site = 1             # <<<<<<<<<<<<<<
 *         for i in range(len(oxygen_positions)):
 *             result = np.vstack((result, self.get_single_molecule_hydrogen_coordinates(site, water_orientations[i], i, oxygen_positions,  nearest_neighbors_nos[0][i], nearest_neighbors_nos[1][i], nearest_neighbors_nos[2][i], self.cell)))
 */
  __pyx_v_site = 1;
 294:         for i in range(len(oxygen_positions)):
  /* "water_algorithm_cython.pyx":294
 *         result = np.zeros((0, 3))
 *         site = 1
 *         for i in range(len(oxygen_positions)):             # <<<<<<<<<<<<<<
 *             result = np.vstack((result, self.get_single_molecule_hydrogen_coordinates(site, water_orientations[i], i, oxygen_positions,  nearest_neighbors_nos[0][i], nearest_neighbors_nos[1][i], nearest_neighbors_nos[2][i], self.cell)))
 *             if site == 4:
 */
  __pyx_t_3 = PyObject_Length(__pyx_v_oxygen_positions); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = 0;
 295:             result = np.vstack((result, self.get_single_molecule_hydrogen_coordinates(site, water_orientations[i], i, oxygen_positions,  nearest_neighbors_nos[0][i], nearest_neighbors_nos[1][i], nearest_neighbors_nos[2][i], self.cell)))
    /* "water_algorithm_cython.pyx":295
 *         site = 1
 *         for i in range(len(oxygen_positions)):
 *             result = np.vstack((result, self.get_single_molecule_hydrogen_coordinates(site, water_orientations[i], i, oxygen_positions,  nearest_neighbors_nos[0][i], nearest_neighbors_nos[1][i], nearest_neighbors_nos[2][i], self.cell)))             # <<<<<<<<<<<<<<
 *             if site == 4:
 *                 site = 1
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__vstack); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetItem(__pyx_v_water_orientations, __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_1); if (unlikely((__pyx_t_6 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_i); if (unlikely((__pyx_t_7 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_v_oxygen_positions);
    if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nearest_neighbors_nos), 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_9);
    if (unlikely(!__pyx_t_10.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nearest_neighbors_nos), 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = PyObject_GetItem(__pyx_t_9, __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_1);
    if (unlikely(!__pyx_t_11.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nearest_neighbors_nos), 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_9);
    if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_v_self->cell);
    if (unlikely(!__pyx_t_13.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_single_molecule_hydrogen_coordinates(__pyx_v_self, __pyx_v_site, __pyx_t_6, __pyx_t_7, __pyx_t_8, __pyx_t_10, __pyx_t_11, __pyx_t_12, __pyx_t_13, 0)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_t_1;
    __pyx_t_1 = 0;
 296:             if site == 4:
    /* "water_algorithm_cython.pyx":296
 *         for i in range(len(oxygen_positions)):
 *             result = np.vstack((result, self.get_single_molecule_hydrogen_coordinates(site, water_orientations[i], i, oxygen_positions,  nearest_neighbors_nos[0][i], nearest_neighbors_nos[1][i], nearest_neighbors_nos[2][i], self.cell)))
 *             if site == 4:             # <<<<<<<<<<<<<<
 *                 site = 1
 *             else:
 */
    __pyx_t_14 = (__pyx_v_site == 4);
    if (__pyx_t_14) {
 297:                 site = 1
      /* "water_algorithm_cython.pyx":297
 *             result = np.vstack((result, self.get_single_molecule_hydrogen_coordinates(site, water_orientations[i], i, oxygen_positions,  nearest_neighbors_nos[0][i], nearest_neighbors_nos[1][i], nearest_neighbors_nos[2][i], self.cell)))
 *             if site == 4:
 *                 site = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 site = site +1
 */
      __pyx_v_site = 1;
      goto __pyx_L5;
    }
    /*else*/ {
 298:             else:
 299:                 site = site +1
      /* "water_algorithm_cython.pyx":299
 *                 site = 1
 *             else:
 *                 site = site +1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
      __pyx_v_site = (__pyx_v_site + 1);
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 300:         return result
  /* "water_algorithm_cython.pyx":300
 *             else:
 *                 site = site +1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def get_all_oxygen_coordinates(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_XDECREF(__pyx_t_9);
  __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_hydrogen_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_15get_all_oxygen_coordinates(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_15get_all_oxygen_coordinates(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_all_oxygen_coordinates (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_14get_all_oxygen_coordinates(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 301: 
 302:     def get_all_oxygen_coordinates(self):
/* "water_algorithm_cython.pyx":302
 *         return result
 * 
 *     def get_all_oxygen_coordinates(self):             # <<<<<<<<<<<<<<
 *         if self.filename != None:
 *             return ase.io.read(self.filename).get_positions()
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_14get_all_oxygen_coordinates(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_all_oxygen_coordinates", 0);
 303:         if self.filename != None:
  /* "water_algorithm_cython.pyx":303
 * 
 *     def get_all_oxygen_coordinates(self):
 *         if self.filename != None:             # <<<<<<<<<<<<<<
 *             return ase.io.read(self.filename).get_positions()
 *         return None
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->filename), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
 304:             return ase.io.read(self.filename).get_positions()
    /* "water_algorithm_cython.pyx":304
 *     def get_all_oxygen_coordinates(self):
 *         if self.filename != None:
 *             return ase.io.read(self.filename).get_positions()             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__io); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->filename));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->filename));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->filename));
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 305:         return None
  /* "water_algorithm_cython.pyx":305
 *         if self.filename != None:
 *             return ase.io.read(self.filename).get_positions()
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def sort_nearest_neighbors(self, molecule_no, sortlist,  result):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_all_oxygen_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_17sort_nearest_neighbors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_16sort_nearest_neighbors[] = "\n            Deprecated\n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_17sort_nearest_neighbors(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_molecule_no = 0;
  CYTHON_UNUSED PyObject *__pyx_v_sortlist = 0;
  CYTHON_UNUSED PyObject *__pyx_v_result = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort_nearest_neighbors (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__molecule_no,&__pyx_n_s__sortlist,&__pyx_n_s__result,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__molecule_no)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sortlist)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sort_nearest_neighbors", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__result)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("sort_nearest_neighbors", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sort_nearest_neighbors") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_molecule_no = values[0];
    __pyx_v_sortlist = values[1];
    __pyx_v_result = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sort_nearest_neighbors", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.sort_nearest_neighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_16sort_nearest_neighbors(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_molecule_no, __pyx_v_sortlist, __pyx_v_result);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 306: 
 307:     def sort_nearest_neighbors(self, molecule_no, sortlist,  result):
/* "water_algorithm_cython.pyx":307
 *         return None
 * 
 *     def sort_nearest_neighbors(self, molecule_no, sortlist,  result):             # <<<<<<<<<<<<<<
 *         """
 *             Deprecated
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_16sort_nearest_neighbors(CYTHON_UNUSED struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_molecule_no, CYTHON_UNUSED PyObject *__pyx_v_sortlist, CYTHON_UNUSED PyObject *__pyx_v_result) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sort_nearest_neighbors", 0);
 308:         """
 309:             Deprecated
 310:         """
 311:         return None
  /* "water_algorithm_cython.pyx":311
 *             Deprecated
 *         """
 *         return None             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_None);
  __pyx_r = Py_None;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_19print_time_stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_19print_time_stats(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_time_stats (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_18print_time_stats(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 312: 
 313: 
 314:     def print_time_stats(self):
/* "water_algorithm_cython.pyx":314
 * 
 * 
 *     def print_time_stats(self):             # <<<<<<<<<<<<<<
 *         time_now = time()
 *         if hasattr(self, 'time_start'):
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_18print_time_stats(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_time_now = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_time_stats", 0);
 315:         time_now = time()
  /* "water_algorithm_cython.pyx":315
 * 
 *     def print_time_stats(self):
 *         time_now = time()             # <<<<<<<<<<<<<<
 *         if hasattr(self, 'time_start'):
 *             self.symmetry_total_time = gather_and_max(self.symmetry_total_time)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_time_now = __pyx_t_2;
  __pyx_t_2 = 0;
 316:         if hasattr(self, 'time_start'):
  /* "water_algorithm_cython.pyx":316
 *     def print_time_stats(self):
 *         time_now = time()
 *         if hasattr(self, 'time_start'):             # <<<<<<<<<<<<<<
 *             self.symmetry_total_time = gather_and_max(self.symmetry_total_time)
 *             self.conversion_time = gather_and_max(self.conversion_time)
 */
  __pyx_t_3 = PyObject_HasAttr(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_n_s__time_start)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {
 317:             self.symmetry_total_time = gather_and_max(self.symmetry_total_time)
    /* "water_algorithm_cython.pyx":317
 *         time_now = time()
 *         if hasattr(self, 'time_start'):
 *             self.symmetry_total_time = gather_and_max(self.symmetry_total_time)             # <<<<<<<<<<<<<<
 *             self.conversion_time = gather_and_max(self.conversion_time)
 *             self.result_group_tryout_time = gather_and_max(self.result_group_tryout_time)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_total_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_total_time, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 318:             self.conversion_time = gather_and_max(self.conversion_time)
    /* "water_algorithm_cython.pyx":318
 *         if hasattr(self, 'time_start'):
 *             self.symmetry_total_time = gather_and_max(self.symmetry_total_time)
 *             self.conversion_time = gather_and_max(self.conversion_time)             # <<<<<<<<<<<<<<
 *             self.result_group_tryout_time = gather_and_max(self.result_group_tryout_time)
 *             self.symmetry_load_time = gather_and_max(self.symmetry_load_time)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 319:             self.result_group_tryout_time = gather_and_max(self.result_group_tryout_time)
    /* "water_algorithm_cython.pyx":319
 *             self.symmetry_total_time = gather_and_max(self.symmetry_total_time)
 *             self.conversion_time = gather_and_max(self.conversion_time)
 *             self.result_group_tryout_time = gather_and_max(self.result_group_tryout_time)             # <<<<<<<<<<<<<<
 *             self.symmetry_load_time = gather_and_max(self.symmetry_load_time)
 *             self.symmetry_check_time = gather_and_max(self.symmetry_check_time)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_29); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_29, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 320:             self.symmetry_load_time = gather_and_max(self.symmetry_load_time)
    /* "water_algorithm_cython.pyx":320
 *             self.conversion_time = gather_and_max(self.conversion_time)
 *             self.result_group_tryout_time = gather_and_max(self.result_group_tryout_time)
 *             self.symmetry_load_time = gather_and_max(self.symmetry_load_time)             # <<<<<<<<<<<<<<
 *             self.symmetry_check_time = gather_and_max(self.symmetry_check_time)
 *             self.iteration_time = gather_and_max(self.iteration_time)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_load_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_load_time, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 321:             self.symmetry_check_time = gather_and_max(self.symmetry_check_time)
    /* "water_algorithm_cython.pyx":321
 *             self.result_group_tryout_time = gather_and_max(self.result_group_tryout_time)
 *             self.symmetry_load_time = gather_and_max(self.symmetry_load_time)
 *             self.symmetry_check_time = gather_and_max(self.symmetry_check_time)             # <<<<<<<<<<<<<<
 *             self.iteration_time = gather_and_max(self.iteration_time)
 *             self.self_symmetry_time = gather_and_max(self.self_symmetry_time)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_check_time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_check_time, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 322:             self.iteration_time = gather_and_max(self.iteration_time)
    /* "water_algorithm_cython.pyx":322
 *             self.symmetry_load_time = gather_and_max(self.symmetry_load_time)
 *             self.symmetry_check_time = gather_and_max(self.symmetry_check_time)
 *             self.iteration_time = gather_and_max(self.iteration_time)             # <<<<<<<<<<<<<<
 *             self.self_symmetry_time = gather_and_max(self.self_symmetry_time)
 *         #Follow the time used
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 323:             self.self_symmetry_time = gather_and_max(self.self_symmetry_time)
    /* "water_algorithm_cython.pyx":323
 *             self.symmetry_check_time = gather_and_max(self.symmetry_check_time)
 *             self.iteration_time = gather_and_max(self.iteration_time)
 *             self.self_symmetry_time = gather_and_max(self.self_symmetry_time)             # <<<<<<<<<<<<<<
 *         #Follow the time used
 *             print_parallel("-------------------------------------------------------------------------", self.logfile)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__self_symmetry_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__self_symmetry_time, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 324:         #Follow the time used
 325:             print_parallel("-------------------------------------------------------------------------", self.logfile)
    /* "water_algorithm_cython.pyx":325
 *             self.self_symmetry_time = gather_and_max(self.self_symmetry_time)
 *         #Follow the time used
 *             print_parallel("-------------------------------------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("Total time elapsed %f s" % (time_now-self.time_start), self.logfile)
 *             print_parallel("  Total time elapsed in symmetry check %f s" % self.symmetry_total_time, self.logfile)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_30));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 326:             print_parallel("Total time elapsed %f s" % (time_now-self.time_start), self.logfile)
    /* "water_algorithm_cython.pyx":326
 *         #Follow the time used
 *             print_parallel("-------------------------------------------------------------------------", self.logfile)
 *             print_parallel("Total time elapsed %f s" % (time_now-self.time_start), self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("  Total time elapsed in symmetry check %f s" % self.symmetry_total_time, self.logfile)
 *             print_parallel("    Time used in bond variable conversion %f s" % self.conversion_time, self.logfile)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__time_start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_Subtract(__pyx_v_time_now, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 327:             print_parallel("  Total time elapsed in symmetry check %f s" % self.symmetry_total_time, self.logfile)
    /* "water_algorithm_cython.pyx":327
 *             print_parallel("-------------------------------------------------------------------------", self.logfile)
 *             print_parallel("Total time elapsed %f s" % (time_now-self.time_start), self.logfile)
 *             print_parallel("  Total time elapsed in symmetry check %f s" % self.symmetry_total_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("    Time used in bond variable conversion %f s" % self.conversion_time, self.logfile)
 *             print_parallel("    Time used trying the result groups %f s" % self.result_group_tryout_time, self.logfile)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_total_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_32), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 328:             print_parallel("    Time used in bond variable conversion %f s" % self.conversion_time, self.logfile)
    /* "water_algorithm_cython.pyx":328
 *             print_parallel("Total time elapsed %f s" % (time_now-self.time_start), self.logfile)
 *             print_parallel("  Total time elapsed in symmetry check %f s" % self.symmetry_total_time, self.logfile)
 *             print_parallel("    Time used in bond variable conversion %f s" % self.conversion_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("    Time used trying the result groups %f s" % self.result_group_tryout_time, self.logfile)
 *             print_parallel("    Time used in symmetry loading %f s" % self.symmetry_load_time, self.logfile)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 329:             print_parallel("    Time used trying the result groups %f s" % self.result_group_tryout_time, self.logfile)
    /* "water_algorithm_cython.pyx":329
 *             print_parallel("  Total time elapsed in symmetry check %f s" % self.symmetry_total_time, self.logfile)
 *             print_parallel("    Time used in bond variable conversion %f s" % self.conversion_time, self.logfile)
 *             print_parallel("    Time used trying the result groups %f s" % self.result_group_tryout_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("    Time used in symmetry loading %f s" % self.symmetry_load_time, self.logfile)
 *             print_parallel("    Time used in symmetry checking %f s" % self.symmetry_check_time, self.logfile)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_29); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 330:             print_parallel("    Time used in symmetry loading %f s" % self.symmetry_load_time, self.logfile)
    /* "water_algorithm_cython.pyx":330
 *             print_parallel("    Time used in bond variable conversion %f s" % self.conversion_time, self.logfile)
 *             print_parallel("    Time used trying the result groups %f s" % self.result_group_tryout_time, self.logfile)
 *             print_parallel("    Time used in symmetry loading %f s" % self.symmetry_load_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("    Time used in symmetry checking %f s" % self.symmetry_check_time, self.logfile)
 *             print_parallel("    Time used in handling of self symmetry groups %f s" % self.self_symmetry_time, self.logfile)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_load_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_35), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 331:             print_parallel("    Time used in symmetry checking %f s" % self.symmetry_check_time, self.logfile)
    /* "water_algorithm_cython.pyx":331
 *             print_parallel("    Time used trying the result groups %f s" % self.result_group_tryout_time, self.logfile)
 *             print_parallel("    Time used in symmetry loading %f s" % self.symmetry_load_time, self.logfile)
 *             print_parallel("    Time used in symmetry checking %f s" % self.symmetry_check_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("    Time used in handling of self symmetry groups %f s" % self.self_symmetry_time, self.logfile)
 *             print_parallel("  Time used in the iteration of water orientations %f s" % self.iteration_time, self.logfile)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_check_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 332:             print_parallel("    Time used in handling of self symmetry groups %f s" % self.self_symmetry_time, self.logfile)
    /* "water_algorithm_cython.pyx":332
 *             print_parallel("    Time used in symmetry loading %f s" % self.symmetry_load_time, self.logfile)
 *             print_parallel("    Time used in symmetry checking %f s" % self.symmetry_check_time, self.logfile)
 *             print_parallel("    Time used in handling of self symmetry groups %f s" % self.self_symmetry_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("  Time used in the iteration of water orientations %f s" % self.iteration_time, self.logfile)
 *             print_parallel(" ------------------------------------------------------------------------", self.logfile)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__self_symmetry_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_37), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 333:             print_parallel("  Time used in the iteration of water orientations %f s" % self.iteration_time, self.logfile)
    /* "water_algorithm_cython.pyx":333
 *             print_parallel("    Time used in symmetry checking %f s" % self.symmetry_check_time, self.logfile)
 *             print_parallel("    Time used in handling of self symmetry groups %f s" % self.self_symmetry_time, self.logfile)
 *             print_parallel("  Time used in the iteration of water orientations %f s" % self.iteration_time, self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel(" ------------------------------------------------------------------------", self.logfile)
 *         self.time_start = time_now
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_38), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 334:             print_parallel(" ------------------------------------------------------------------------", self.logfile)
    /* "water_algorithm_cython.pyx":334
 *             print_parallel("    Time used in handling of self symmetry groups %f s" % self.self_symmetry_time, self.logfile)
 *             print_parallel("  Time used in the iteration of water orientations %f s" % self.iteration_time, self.logfile)
 *             print_parallel(" ------------------------------------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *         self.time_start = time_now
 *         self.symmetry_load_time = 0
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_39));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_39));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_39));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 335:         self.time_start = time_now
  /* "water_algorithm_cython.pyx":335
 *             print_parallel("  Time used in the iteration of water orientations %f s" % self.iteration_time, self.logfile)
 *             print_parallel(" ------------------------------------------------------------------------", self.logfile)
 *         self.time_start = time_now             # <<<<<<<<<<<<<<
 *         self.symmetry_load_time = 0
 *         self.symmetry_check_time = 0
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__time_start, __pyx_v_time_now) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 336:         self.symmetry_load_time = 0
  /* "water_algorithm_cython.pyx":336
 *             print_parallel(" ------------------------------------------------------------------------", self.logfile)
 *         self.time_start = time_now
 *         self.symmetry_load_time = 0             # <<<<<<<<<<<<<<
 *         self.symmetry_check_time = 0
 *         self.iteration_time = 0
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_load_time, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 337:         self.symmetry_check_time = 0
  /* "water_algorithm_cython.pyx":337
 *         self.time_start = time_now
 *         self.symmetry_load_time = 0
 *         self.symmetry_check_time = 0             # <<<<<<<<<<<<<<
 *         self.iteration_time = 0
 *         self.symmetry_total_time = 0
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_check_time, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 338:         self.iteration_time = 0
  /* "water_algorithm_cython.pyx":338
 *         self.symmetry_load_time = 0
 *         self.symmetry_check_time = 0
 *         self.iteration_time = 0             # <<<<<<<<<<<<<<
 *         self.symmetry_total_time = 0
 *         self.self_symmetry_time = 0
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 339:         self.symmetry_total_time = 0
  /* "water_algorithm_cython.pyx":339
 *         self.symmetry_check_time = 0
 *         self.iteration_time = 0
 *         self.symmetry_total_time = 0             # <<<<<<<<<<<<<<
 *         self.self_symmetry_time = 0
 *         self.result_group_tryout_time = 0
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_total_time, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 340:         self.self_symmetry_time = 0
  /* "water_algorithm_cython.pyx":340
 *         self.iteration_time = 0
 *         self.symmetry_total_time = 0
 *         self.self_symmetry_time = 0             # <<<<<<<<<<<<<<
 *         self.result_group_tryout_time = 0
 *         self.conversion_time = 0
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__self_symmetry_time, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 341:         self.result_group_tryout_time = 0
  /* "water_algorithm_cython.pyx":341
 *         self.symmetry_total_time = 0
 *         self.self_symmetry_time = 0
 *         self.result_group_tryout_time = 0             # <<<<<<<<<<<<<<
 *         self.conversion_time = 0
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_29, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 342:         self.conversion_time = 0
  /* "water_algorithm_cython.pyx":342
 *         self.self_symmetry_time = 0
 *         self.result_group_tryout_time = 0
 *         self.conversion_time = 0             # <<<<<<<<<<<<<<
 * 
 *     def get_folder(self):
 */
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.print_time_stats", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_time_now);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_21get_folder(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_21get_folder(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_folder (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_20get_folder(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 343: 
 344:     def get_folder(self):
/* "water_algorithm_cython.pyx":344
 *         self.conversion_time = 0
 * 
 *     def get_folder(self):             # <<<<<<<<<<<<<<
 *         if self.folder == None or self.folder=="":
 *             try:
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_20get_folder(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_dot_index = NULL;
  PyObject *__pyx_v_folder = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_folder", 0);
 345:         if self.folder == None or self.folder=="":
  /* "water_algorithm_cython.pyx":345
 * 
 *     def get_folder(self):
 *         if self.folder == None or self.folder=="":             # <<<<<<<<<<<<<<
 *             try:
 *                 if self.filename != None and self.filename != '':
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->folder), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!__pyx_t_2) {
    __pyx_t_3 = (__Pyx_PyBytes_Equals(((PyObject *)__pyx_v_self->folder), ((PyObject *)__pyx_kp_s_1), Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {
 346:             try:
    /* "water_algorithm_cython.pyx":346
 *     def get_folder(self):
 *         if self.folder == None or self.folder=="":
 *             try:             # <<<<<<<<<<<<<<
 *                 if self.filename != None and self.filename != '':
 *                     dot_index = self.filename.rfind('.')
 */
    {
      __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      /*try:*/ {
 347:                 if self.filename != None and self.filename != '':
        /* "water_algorithm_cython.pyx":347
 *         if self.folder == None or self.folder=="":
 *             try:
 *                 if self.filename != None and self.filename != '':             # <<<<<<<<<<<<<<
 *                     dot_index = self.filename.rfind('.')
 *                     if dot_index != -1:
 */
        __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->filename), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_4) {
          __pyx_t_2 = (__Pyx_PyBytes_Equals(((PyObject *)__pyx_v_self->filename), ((PyObject *)__pyx_kp_s_1), Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __pyx_t_3 = __pyx_t_2;
        } else {
          __pyx_t_3 = __pyx_t_4;
        }
        if (__pyx_t_3) {
 348:                     dot_index = self.filename.rfind('.')
          /* "water_algorithm_cython.pyx":348
 *             try:
 *                 if self.filename != None and self.filename != '':
 *                     dot_index = self.filename.rfind('.')             # <<<<<<<<<<<<<<
 *                     if dot_index != -1:
 *                         self.folder = self.filename[:dot_index]
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->filename), __pyx_n_s__rfind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v_dot_index = __pyx_t_8;
          __pyx_t_8 = 0;

  /* "water_algorithm_cython.pyx":348
 *             try:
 *                 if self.filename != None and self.filename != '':
 *                     dot_index = self.filename.rfind('.')             # <<<<<<<<<<<<<<
 *                     if dot_index != -1:
 *                         self.folder = self.filename[:dot_index]
 */
  __pyx_k_tuple_41 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_40)); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_41);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
 349:                     if dot_index != -1:
          /* "water_algorithm_cython.pyx":349
 *                 if self.filename != None and self.filename != '':
 *                     dot_index = self.filename.rfind('.')
 *                     if dot_index != -1:             # <<<<<<<<<<<<<<
 *                         self.folder = self.filename[:dot_index]
 *                     else:
 */
          __pyx_t_8 = PyObject_RichCompare(__pyx_v_dot_index, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 349; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (__pyx_t_3) {
 350:                         self.folder = self.filename[:dot_index]
            /* "water_algorithm_cython.pyx":350
 *                     dot_index = self.filename.rfind('.')
 *                     if dot_index != -1:
 *                         self.folder = self.filename[:dot_index]             # <<<<<<<<<<<<<<
 *                     else:
 *                         raise Exception()
 */
            if (unlikely(((PyObject *)__pyx_v_self->filename) == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            }
            __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_dot_index); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            __pyx_t_8 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_self->filename), 0, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_8));
            __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
            __Pyx_GOTREF(__pyx_v_self->folder);
            __Pyx_DECREF(((PyObject *)__pyx_v_self->folder));
            __pyx_v_self->folder = ((PyObject*)__pyx_t_8);
            __pyx_t_8 = 0;
            goto __pyx_L13;
          }
          /*else*/ {
 351:                     else:
 352:                         raise Exception()
            /* "water_algorithm_cython.pyx":352
 *                         self.folder = self.filename[:dot_index]
 *                     else:
 *                         raise Exception()             # <<<<<<<<<<<<<<
 *             except:
 *                 print "Deducing folder name from input file name failed, falling back to current directory."
 */
            __pyx_t_8 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_Raise(__pyx_t_8, 0, 0, 0);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
          }
          __pyx_L13:;
          goto __pyx_L12;
        }
        __pyx_L12:;
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L11_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
 353:             except:
      /* "water_algorithm_cython.pyx":353
 *                     else:
 *                         raise Exception()
 *             except:             # <<<<<<<<<<<<<<
 *                 print "Deducing folder name from input file name failed, falling back to current directory."
 *             folder = "./"
 */
      /*except:*/ {
        __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_folder", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_1, &__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_t_10);
 354:                 print "Deducing folder name from input file name failed, falling back to current directory."
        /* "water_algorithm_cython.pyx":354
 *                         raise Exception()
 *             except:
 *                 print "Deducing folder name from input file name failed, falling back to current directory."             # <<<<<<<<<<<<<<
 *             folder = "./"
 *         else:
 */
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_42)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L5_exception_handled;
      }
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_5);
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
      __pyx_L11_try_end:;
    }
 355:             folder = "./"
    /* "water_algorithm_cython.pyx":355
 *             except:
 *                 print "Deducing folder name from input file name failed, falling back to current directory."
 *             folder = "./"             # <<<<<<<<<<<<<<
 *         else:
 *             folder = self.folder+"/"
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
    __pyx_v_folder = ((PyObject *)__pyx_kp_s_43);
    goto __pyx_L3;
  }
  /*else*/ {
 356:         else:
 357:             folder = self.folder+"/"
    /* "water_algorithm_cython.pyx":357
 *             folder = "./"
 *         else:
 *             folder = self.folder+"/"             # <<<<<<<<<<<<<<
 * 
 *         if rank == 0 and not os.path.exists(folder):
 */
    __pyx_t_10 = PyNumber_Add(((PyObject *)__pyx_v_self->folder), ((PyObject *)__pyx_kp_s_44)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_v_folder = __pyx_t_10;
    __pyx_t_10 = 0;
  }
  __pyx_L3:;
 358: 
 359:         if rank == 0 and not os.path.exists(folder):
  /* "water_algorithm_cython.pyx":359
 *             folder = self.folder+"/"
 * 
 *         if rank == 0 and not os.path.exists(folder):             # <<<<<<<<<<<<<<
 *             os.makedirs(folder)
 * 
 */
  __pyx_t_3 = (rank == 0);
  if (__pyx_t_3) {
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__exists); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_folder);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_folder);
    __Pyx_GIVEREF(__pyx_v_folder);
    __pyx_t_8 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_2 = (!__pyx_t_4);
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  if (__pyx_t_4) {
 360:             os.makedirs(folder)
    /* "water_algorithm_cython.pyx":360
 * 
 *         if rank == 0 and not os.path.exists(folder):
 *             os.makedirs(folder)             # <<<<<<<<<<<<<<
 * 
 *         return folder
 */
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s__makedirs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_folder);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_folder);
    __Pyx_GIVEREF(__pyx_v_folder);
    __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L16;
  }
  __pyx_L16:;
 361: 
 362:         return folder
  /* "water_algorithm_cython.pyx":362
 *             os.makedirs(folder)
 * 
 *         return folder             # <<<<<<<<<<<<<<
 * 
 *     def write(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_folder);
  __pyx_r = __pyx_v_folder;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_folder", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dot_index);
  __Pyx_XDECREF(__pyx_v_folder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_23write(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_23write(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_22write(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 363: 
 364:     def write(self):
/* "water_algorithm_cython.pyx":364
 *         return folder
 * 
 *     def write(self):             # <<<<<<<<<<<<<<
 *         wos = self.load_results(False)
 *         if wos is not None:
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_22write(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_wos = NULL;
  PyObject *__pyx_v_folder = NULL;
  PyObject *__pyx_v_additional_atoms = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write", 0);
 365:         wos = self.load_results(False)
  /* "water_algorithm_cython.pyx":365
 * 
 *     def write(self):
 *         wos = self.load_results(False)             # <<<<<<<<<<<<<<
 *         if wos is not None:
 *             folder = self.get_folder()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__load_results); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_wos = __pyx_t_2;
  __pyx_t_2 = 0;
 366:         if wos is not None:
  /* "water_algorithm_cython.pyx":366
 *     def write(self):
 *         wos = self.load_results(False)
 *         if wos is not None:             # <<<<<<<<<<<<<<
 *             folder = self.get_folder()
 *             if not os.path.exists(folder+"originals/"):
 */
  __pyx_t_4 = (__pyx_v_wos != Py_None);
  if (__pyx_t_4) {
 367:             folder = self.get_folder()
    /* "water_algorithm_cython.pyx":367
 *         wos = self.load_results(False)
 *         if wos is not None:
 *             folder = self.get_folder()             # <<<<<<<<<<<<<<
 *             if not os.path.exists(folder+"originals/"):
 *                 os.makedirs(folder+"originals/")
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_folder = __pyx_t_3;
    __pyx_t_3 = 0;
 368:             if not os.path.exists(folder+"originals/"):
    /* "water_algorithm_cython.pyx":368
 *         if wos is not None:
 *             folder = self.get_folder()
 *             if not os.path.exists(folder+"originals/"):             # <<<<<<<<<<<<<<
 *                 os.makedirs(folder+"originals/")
 *             additional_atoms = None
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = (!__pyx_t_4);
    if (__pyx_t_5) {
 369:                 os.makedirs(folder+"originals/")
      /* "water_algorithm_cython.pyx":369
 *             folder = self.get_folder()
 *             if not os.path.exists(folder+"originals/"):
 *                 os.makedirs(folder+"originals/")             # <<<<<<<<<<<<<<
 *             additional_atoms = None
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__makedirs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
 370:             additional_atoms = None
    /* "water_algorithm_cython.pyx":370
 *             if not os.path.exists(folder+"originals/"):
 *                 os.makedirs(folder+"originals/")
 *             additional_atoms = None             # <<<<<<<<<<<<<<
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_additional_atoms = Py_None;
 371:             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
    /* "water_algorithm_cython.pyx":371
 *                 os.makedirs(folder+"originals/")
 *             additional_atoms = None
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):             # <<<<<<<<<<<<<<
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 *             print self.cell
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = (__pyx_t_2 != Py_None);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_5) {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_kp_s_1), Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_4) {
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_4;
      }
      __pyx_t_4 = __pyx_t_7;
    } else {
      __pyx_t_4 = __pyx_t_5;
    }
    if (__pyx_t_4) {
 372:                 additional_atoms = ase.io.read(self.additional_atoms)
      /* "water_algorithm_cython.pyx":372
 *             additional_atoms = None
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *                 additional_atoms = ase.io.read(self.additional_atoms)             # <<<<<<<<<<<<<<
 *             print self.cell
 *             write_results_to_file(self,  self.oxygen_coordinates, wos, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__io); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__read); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_additional_atoms);
      __pyx_v_additional_atoms = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
 373:             print self.cell
    /* "water_algorithm_cython.pyx":373
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 *             print self.cell             # <<<<<<<<<<<<<<
 *             write_results_to_file(self,  self.oxygen_coordinates, wos, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms)
 *             print "Geometries written to folder \"%s\" successfully." % (folder+"originals/")
 */
    if (__Pyx_PrintOne(0, __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 374:             write_results_to_file(self,  self.oxygen_coordinates, wos, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms)
    /* "water_algorithm_cython.pyx":374
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 *             print self.cell
 *             write_results_to_file(self,  self.oxygen_coordinates, wos, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms)             # <<<<<<<<<<<<<<
 *             print "Geometries written to folder \"%s\" successfully." % (folder+"originals/")
 *         else:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_46); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self->oxygen_coordinates));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
    __Pyx_INCREF(__pyx_v_wos);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_wos);
    __Pyx_GIVEREF(__pyx_v_wos);
    __Pyx_INCREF(__pyx_v_self->cell);
    PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->cell);
    __Pyx_GIVEREF(__pyx_v_self->cell);
    PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_8 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__folder), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__periodic), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__additional_atoms), __pyx_v_additional_atoms) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 375:             print "Geometries written to folder \"%s\" successfully." % (folder+"originals/")
    /* "water_algorithm_cython.pyx":375
 *             print self.cell
 *             write_results_to_file(self,  self.oxygen_coordinates, wos, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms)
 *             print "Geometries written to folder \"%s\" successfully." % (folder+"originals/")             # <<<<<<<<<<<<<<
 *         else:
 *             print "Geometries could not be loaded. Execute the algorithm first with \"--execute\"."
 */
    __pyx_t_8 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), __pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 376:         else:
 377:             print "Geometries could not be loaded. Execute the algorithm first with \"--execute\"."
    /* "water_algorithm_cython.pyx":377
 *             print "Geometries written to folder \"%s\" successfully." % (folder+"originals/")
 *         else:
 *             print "Geometries could not be loaded. Execute the algorithm first with \"--execute\"."             # <<<<<<<<<<<<<<
 * 
 *     def initialize_cell(self, cell):
 */
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_48)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wos);
  __Pyx_XDECREF(__pyx_v_folder);
  __Pyx_XDECREF(__pyx_v_additional_atoms);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_25initialize_cell(PyObject *__pyx_v_self, PyObject *__pyx_v_cell); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_25initialize_cell(PyObject *__pyx_v_self, PyObject *__pyx_v_cell) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize_cell (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_24initialize_cell(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_cell));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 378: 
 379:     def initialize_cell(self, cell):
/* "water_algorithm_cython.pyx":379
 *             print "Geometries could not be loaded. Execute the algorithm first with \"--execute\"."
 * 
 *     def initialize_cell(self, cell):             # <<<<<<<<<<<<<<
 *         additional_atoms = None
 *         additional_atoms_cell = None
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_24initialize_cell(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_cell) {
  PyObject *__pyx_v_additional_atoms = NULL;
  PyObject *__pyx_v_additional_atoms_cell = NULL;
  PyObject *__pyx_v_sys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("initialize_cell", 0);
 380:         additional_atoms = None
  /* "water_algorithm_cython.pyx":380
 * 
 *     def initialize_cell(self, cell):
 *         additional_atoms = None             # <<<<<<<<<<<<<<
 *         additional_atoms_cell = None
 *         if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_additional_atoms = Py_None;
 381:         additional_atoms_cell = None
  /* "water_algorithm_cython.pyx":381
 *     def initialize_cell(self, cell):
 *         additional_atoms = None
 *         additional_atoms_cell = None             # <<<<<<<<<<<<<<
 *         if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *             additional_atoms = ase.io.read(self.additional_atoms)
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_additional_atoms_cell = Py_None;
 382:         if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
  /* "water_algorithm_cython.pyx":382
 *         additional_atoms = None
 *         additional_atoms_cell = None
 *         if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):             # <<<<<<<<<<<<<<
 *             additional_atoms = ase.io.read(self.additional_atoms)
 *             additional_atoms_cell = additional_atoms.get_cell()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__pyx_t_1 != Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_kp_s_1), Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_4) {
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_7 = __pyx_t_4;
    }
    __pyx_t_4 = __pyx_t_7;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {
 383:             additional_atoms = ase.io.read(self.additional_atoms)
    /* "water_algorithm_cython.pyx":383
 *         additional_atoms_cell = None
 *         if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *             additional_atoms = ase.io.read(self.additional_atoms)             # <<<<<<<<<<<<<<
 *             additional_atoms_cell = additional_atoms.get_cell()
 *         if cell is None:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__io); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_additional_atoms);
    __pyx_v_additional_atoms = __pyx_t_5;
    __pyx_t_5 = 0;
 384:             additional_atoms_cell = additional_atoms.get_cell()
    /* "water_algorithm_cython.pyx":384
 *         if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *             additional_atoms = ase.io.read(self.additional_atoms)
 *             additional_atoms_cell = additional_atoms.get_cell()             # <<<<<<<<<<<<<<
 *         if cell is None:
 *             if additional_atoms_cell is None:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_atoms, __pyx_n_s__get_cell); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_additional_atoms_cell);
    __pyx_v_additional_atoms_cell = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 385:         if cell is None:
  /* "water_algorithm_cython.pyx":385
 *             additional_atoms = ase.io.read(self.additional_atoms)
 *             additional_atoms_cell = additional_atoms.get_cell()
 *         if cell is None:             # <<<<<<<<<<<<<<
 *             if additional_atoms_cell is None:
 *                 if type(self.periodic) != bool or self.periodic:
 */
  __pyx_t_4 = (__pyx_v_cell == Py_None);
  if (__pyx_t_4) {
 386:             if additional_atoms_cell is None:
    /* "water_algorithm_cython.pyx":386
 *             additional_atoms_cell = additional_atoms.get_cell()
 *         if cell is None:
 *             if additional_atoms_cell is None:             # <<<<<<<<<<<<<<
 *                 if type(self.periodic) != bool or self.periodic:
 *                     import sys
 */
    __pyx_t_4 = (__pyx_v_additional_atoms_cell == Py_None);
    if (__pyx_t_4) {
 387:                 if type(self.periodic) != bool or self.periodic:
      /* "water_algorithm_cython.pyx":387
 *         if cell is None:
 *             if additional_atoms_cell is None:
 *                 if type(self.periodic) != bool or self.periodic:             # <<<<<<<<<<<<<<
 *                     import sys
 *                     sys.exit("Invalid cell input. The system is set to be periodic, but any cell is not available.")
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_3)), ((PyObject *)((PyObject*)__pyx_ptype_7cpython_4bool_bool)), Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!__pyx_t_4) {
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_7 = __pyx_t_2;
      } else {
        __pyx_t_7 = __pyx_t_4;
      }
      if (__pyx_t_7) {
 388:                     import sys
        /* "water_algorithm_cython.pyx":388
 *             if additional_atoms_cell is None:
 *                 if type(self.periodic) != bool or self.periodic:
 *                     import sys             # <<<<<<<<<<<<<<
 *                     sys.exit("Invalid cell input. The system is set to be periodic, but any cell is not available.")
 *             else:
 */
        __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_v_sys = __pyx_t_5;
        __pyx_t_5 = 0;
 389:                     sys.exit("Invalid cell input. The system is set to be periodic, but any cell is not available.")
        /* "water_algorithm_cython.pyx":389
 *                 if type(self.periodic) != bool or self.periodic:
 *                     import sys
 *                     sys.exit("Invalid cell input. The system is set to be periodic, but any cell is not available.")             # <<<<<<<<<<<<<<
 *             else:
 *                 self.cell = additional_atoms_cell
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_sys, __pyx_n_s__exit); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {

  /* "water_algorithm_cython.pyx":389
 *                 if type(self.periodic) != bool or self.periodic:
 *                     import sys
 *                     sys.exit("Invalid cell input. The system is set to be periodic, but any cell is not available.")             # <<<<<<<<<<<<<<
 *             else:
 *                 self.cell = additional_atoms_cell
 */
  __pyx_k_tuple_50 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_49)); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_50);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50));
 390:             else:
 391:                 self.cell = additional_atoms_cell
      /* "water_algorithm_cython.pyx":391
 *                     sys.exit("Invalid cell input. The system is set to be periodic, but any cell is not available.")
 *             else:
 *                 self.cell = additional_atoms_cell             # <<<<<<<<<<<<<<
 *         else:
 *             self.cell = cell
 */
      __Pyx_INCREF(__pyx_v_additional_atoms_cell);
      __Pyx_GIVEREF(__pyx_v_additional_atoms_cell);
      __Pyx_GOTREF(__pyx_v_self->cell);
      __Pyx_DECREF(__pyx_v_self->cell);
      __pyx_v_self->cell = __pyx_v_additional_atoms_cell;
    }
    __pyx_L5:;
    goto __pyx_L4;
  }
  /*else*/ {
 392:         else:
 393:             self.cell = cell
    /* "water_algorithm_cython.pyx":393
 *                 self.cell = additional_atoms_cell
 *         else:
 *             self.cell = cell             # <<<<<<<<<<<<<<
 * 
 *     def write_structure(self, number):
 */
    __Pyx_INCREF(__pyx_v_cell);
    __Pyx_GIVEREF(__pyx_v_cell);
    __Pyx_GOTREF(__pyx_v_self->cell);
    __Pyx_DECREF(__pyx_v_self->cell);
    __pyx_v_self->cell = __pyx_v_cell;
  }
  __pyx_L4:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.initialize_cell", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_additional_atoms);
  __Pyx_XDECREF(__pyx_v_additional_atoms_cell);
  __Pyx_XDECREF(__pyx_v_sys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_27write_structure(PyObject *__pyx_v_self, PyObject *__pyx_v_number); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_27write_structure(PyObject *__pyx_v_self, PyObject *__pyx_v_number) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_structure (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_26write_structure(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_number));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 394: 
 395:     def write_structure(self, number):
/* "water_algorithm_cython.pyx":395
 *             self.cell = cell
 * 
 *     def write_structure(self, number):             # <<<<<<<<<<<<<<
 *         number = int(number)
 *         wo = self.load_single_result(number)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_26write_structure(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_number) {
  PyObject *__pyx_v_wo = NULL;
  PyObject *__pyx_v_folder = NULL;
  PyObject *__pyx_v_additional_atoms = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_structure", 0);
  __Pyx_INCREF(__pyx_v_number);
 396:         number = int(number)
  /* "water_algorithm_cython.pyx":396
 * 
 *     def write_structure(self, number):
 *         number = int(number)             # <<<<<<<<<<<<<<
 *         wo = self.load_single_result(number)
 *         if wo is not None:
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_number);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_number);
  __Pyx_GIVEREF(__pyx_v_number);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_number);
  __pyx_v_number = __pyx_t_2;
  __pyx_t_2 = 0;
 397:         wo = self.load_single_result(number)
  /* "water_algorithm_cython.pyx":397
 *     def write_structure(self, number):
 *         number = int(number)
 *         wo = self.load_single_result(number)             # <<<<<<<<<<<<<<
 *         if wo is not None:
 *             folder = self.get_folder()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__load_single_result); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_number);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_number);
  __Pyx_GIVEREF(__pyx_v_number);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_wo = __pyx_t_3;
  __pyx_t_3 = 0;
 398:         if wo is not None:
  /* "water_algorithm_cython.pyx":398
 *         number = int(number)
 *         wo = self.load_single_result(number)
 *         if wo is not None:             # <<<<<<<<<<<<<<
 *             folder = self.get_folder()
 *             if not os.path.exists(folder+"originals/"):
 */
  __pyx_t_4 = (__pyx_v_wo != Py_None);
  if (__pyx_t_4) {
 399:             folder = self.get_folder()
    /* "water_algorithm_cython.pyx":399
 *         wo = self.load_single_result(number)
 *         if wo is not None:
 *             folder = self.get_folder()             # <<<<<<<<<<<<<<
 *             if not os.path.exists(folder+"originals/"):
 *                 os.makedirs(folder+"originals/")
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_folder = __pyx_t_1;
    __pyx_t_1 = 0;
 400:             if not os.path.exists(folder+"originals/"):
    /* "water_algorithm_cython.pyx":400
 *         if wo is not None:
 *             folder = self.get_folder()
 *             if not os.path.exists(folder+"originals/"):             # <<<<<<<<<<<<<<
 *                 os.makedirs(folder+"originals/")
 *             additional_atoms = None
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = (!__pyx_t_4);
    if (__pyx_t_5) {
 401:                 os.makedirs(folder+"originals/")
      /* "water_algorithm_cython.pyx":401
 *             folder = self.get_folder()
 *             if not os.path.exists(folder+"originals/"):
 *                 os.makedirs(folder+"originals/")             # <<<<<<<<<<<<<<
 *             additional_atoms = None
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__makedirs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L4;
    }
    __pyx_L4:;
 402:             additional_atoms = None
    /* "water_algorithm_cython.pyx":402
 *             if not os.path.exists(folder+"originals/"):
 *                 os.makedirs(folder+"originals/")
 *             additional_atoms = None             # <<<<<<<<<<<<<<
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_additional_atoms = Py_None;
 403:             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
    /* "water_algorithm_cython.pyx":403
 *                 os.makedirs(folder+"originals/")
 *             additional_atoms = None
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):             # <<<<<<<<<<<<<<
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 *             write_result_to_file(self, self.oxygen_coordinate, wo, number, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms, vacuum = self.vacuum)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = (__pyx_t_3 != Py_None);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_5) {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_kp_s_1), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_4) {
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_4;
      }
      __pyx_t_4 = __pyx_t_7;
    } else {
      __pyx_t_4 = __pyx_t_5;
    }
    if (__pyx_t_4) {
 404:                 additional_atoms = ase.io.read(self.additional_atoms)
      /* "water_algorithm_cython.pyx":404
 *             additional_atoms = None
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *                 additional_atoms = ase.io.read(self.additional_atoms)             # <<<<<<<<<<<<<<
 *             write_result_to_file(self, self.oxygen_coordinate, wo, number, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms, vacuum = self.vacuum)
 *             print "Geometry number %i written to folder \"%s\" successfully." % (number, folder+"originals/")
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__io); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__read); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_additional_atoms);
      __pyx_v_additional_atoms = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
 405:             write_result_to_file(self, self.oxygen_coordinate, wo, number, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms, vacuum = self.vacuum)
    /* "water_algorithm_cython.pyx":405
 *             if (self.additional_atoms is not None and self.additional_atoms != '' and os.path.exists(self.additional_atoms)):
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 *             write_result_to_file(self, self.oxygen_coordinate, wo, number, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms, vacuum = self.vacuum)             # <<<<<<<<<<<<<<
 *             print "Geometry number %i written to folder \"%s\" successfully." % (number, folder+"originals/")
 *         else:
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_51); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__oxygen_coordinate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = PyTuple_New(6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_wo);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_wo);
    __Pyx_GIVEREF(__pyx_v_wo);
    __Pyx_INCREF(__pyx_v_number);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_number);
    __Pyx_GIVEREF(__pyx_v_number);
    __Pyx_INCREF(__pyx_v_self->cell);
    PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_v_self->cell);
    __Pyx_GIVEREF(__pyx_v_self->cell);
    PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_1 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__folder), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__periodic), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__additional_atoms), __pyx_v_additional_atoms) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__vacuum); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__vacuum), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_8), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 406:             print "Geometry number %i written to folder \"%s\" successfully." % (number, folder+"originals/")
    /* "water_algorithm_cython.pyx":406
 *                 additional_atoms = ase.io.read(self.additional_atoms)
 *             write_result_to_file(self, self.oxygen_coordinate, wo, number, self.cell,  self.nearest_neighbors_nos,  folder=folder+"originals/", periodic = self.periodic, additional_atoms = additional_atoms, vacuum = self.vacuum)
 *             print "Geometry number %i written to folder \"%s\" successfully." % (number, folder+"originals/")             # <<<<<<<<<<<<<<
 *         else:
 *             print "Geometry could not be loaded. Assert that there is enought results or that the algorithm has been executed with \"--execute\"."
 */
    __pyx_t_1 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_45)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_number);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_number);
    __Pyx_GIVEREF(__pyx_v_number);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 407:         else:
 408:             print "Geometry could not be loaded. Assert that there is enought results or that the algorithm has been executed with \"--execute\"."
    /* "water_algorithm_cython.pyx":408
 *             print "Geometry number %i written to folder \"%s\" successfully." % (number, folder+"originals/")
 *         else:
 *             print "Geometry could not be loaded. Assert that there is enought results or that the algorithm has been executed with \"--execute\"."             # <<<<<<<<<<<<<<
 * 
 * 
 */
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_53)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write_structure", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wo);
  __Pyx_XDECREF(__pyx_v_folder);
  __Pyx_XDECREF(__pyx_v_additional_atoms);
  __Pyx_XDECREF(__pyx_v_number);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_29save_results(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_28save_results[] = "\n            If i is in intermediate saves save only a text file containing water orientations\n                -if not, then do nothing\n            If i is the last molecule to be handled, then save the water_orientations also\n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_29save_results(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned char __pyx_v_i;
  PyObject *__pyx_v_water_orientations = 0;
  PyObject *__pyx_v_order = 0;
  PyObject *__pyx_v_group_save = 0;
  PyObject *__pyx_v_group_number = 0;
  CYTHON_UNUSED PyObject *__pyx_v_all_symmetries_found = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save_results (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i,&__pyx_n_s__water_orientations,&__pyx_n_s__order,&__pyx_n_s__group_save,&__pyx_n_s__group_number,&__pyx_n_s_54,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[3] = __pyx_k_55;
    values[4] = ((PyObject *)__pyx_int_neg_1);
    values[5] = __pyx_k_56;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("save_results", 0, 3, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__order)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("save_results", 0, 3, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group_save);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group_number);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_54);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "save_results") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_i = __Pyx_PyInt_AsUnsignedChar(values[0]); if (unlikely((__pyx_v_i == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_water_orientations = values[1];
    __pyx_v_order = values[2];
    __pyx_v_group_save = values[3];
    __pyx_v_group_number = values[4];
    __pyx_v_all_symmetries_found = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("save_results", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.save_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_28save_results(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_i, __pyx_v_water_orientations, __pyx_v_order, __pyx_v_group_save, __pyx_v_group_number, __pyx_v_all_symmetries_found);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 409: 
 410: 
 411: 
 412:     def save_results(self, unsigned char i, water_orientations, order, group_save=False, group_number=-1, all_symmetries_found = False):
/* "water_algorithm_cython.pyx":412
 * 
 * 
 *     def save_results(self, unsigned char i, water_orientations, order, group_save=False, group_number=-1, all_symmetries_found = False):             # <<<<<<<<<<<<<<
 *         """
 *             If i is in intermediate saves save only a text file containing water orientations
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_28save_results(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, unsigned char __pyx_v_i, PyObject *__pyx_v_water_orientations, PyObject *__pyx_v_order, PyObject *__pyx_v_group_save, PyObject *__pyx_v_group_number, CYTHON_UNUSED PyObject *__pyx_v_all_symmetries_found) {
  unsigned char __pyx_v_j;
  PyObject *__pyx_v_mode = NULL;
  int __pyx_v_continue_sequence;
  PyObject *__pyx_v_ar_file = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_cs = NULL;
  PyObject *__pyx_v_folder = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save_results", 0);

  /* "water_algorithm_cython.pyx":412
 * 
 * 
 *     def save_results(self, unsigned char i, water_orientations, order, group_save=False, group_number=-1, all_symmetries_found = False):             # <<<<<<<<<<<<<<
 *         """
 *             If i is in intermediate saves save only a text file containing water orientations
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_55 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_56 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
 413:         """
 414:             If i is in intermediate saves save only a text file containing water orientations
 415:                 -if not, then do nothing
 416:             If i is the last molecule to be handled, then save the water_orientations also
 417:         """
 418:         if not group_save and i == order[len(order)-1]:
  /* "water_algorithm_cython.pyx":418
 *             If i is the last molecule to be handled, then save the water_orientations also
 *         """
 *         if not group_save and i == order[len(order)-1]:             # <<<<<<<<<<<<<<
 *             for j in range(size):
 *                 if rank == j  and i == order[len(order)-1]:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_group_save); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {
    __pyx_t_3 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Length(__pyx_v_order); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = (__pyx_t_4 - 1);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_order, __pyx_t_5, sizeof(Py_ssize_t), PyInt_FromSsize_t, 0, 0, 0); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __pyx_t_1;
  } else {
    __pyx_t_8 = __pyx_t_2;
  }
  if (__pyx_t_8) {
 419:             for j in range(size):
    /* "water_algorithm_cython.pyx":419
 *         """
 *         if not group_save and i == order[len(order)-1]:
 *             for j in range(size):             # <<<<<<<<<<<<<<
 *                 if rank == j  and i == order[len(order)-1]:
 *                     if j == 0:
 */
    __pyx_t_9 = size;
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_v_j = __pyx_t_10;
 420:                 if rank == j  and i == order[len(order)-1]:
      /* "water_algorithm_cython.pyx":420
 *         if not group_save and i == order[len(order)-1]:
 *             for j in range(size):
 *                 if rank == j  and i == order[len(order)-1]:             # <<<<<<<<<<<<<<
 *                     if j == 0:
 *                         mode = "wb"
 */
      __pyx_t_8 = (rank == __pyx_v_j);
      if (__pyx_t_8) {
        __pyx_t_7 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = PyObject_Length(__pyx_v_order); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = (__pyx_t_5 - 1);
        __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_order, __pyx_t_4, sizeof(Py_ssize_t), PyInt_FromSsize_t, 0, 0, 0); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_1 = __pyx_t_2;
      } else {
        __pyx_t_1 = __pyx_t_8;
      }
      if (__pyx_t_1) {
 421:                     if j == 0:
        /* "water_algorithm_cython.pyx":421
 *             for j in range(size):
 *                 if rank == j  and i == order[len(order)-1]:
 *                     if j == 0:             # <<<<<<<<<<<<<<
 *                         mode = "wb"
 *                     else:
 */
        __pyx_t_1 = (__pyx_v_j == 0);
        if (__pyx_t_1) {
 422:                         mode = "wb"
          /* "water_algorithm_cython.pyx":422
 *                 if rank == j  and i == order[len(order)-1]:
 *                     if j == 0:
 *                         mode = "wb"             # <<<<<<<<<<<<<<
 *                     else:
 *                         mode = "ab+"
 */
          __Pyx_INCREF(((PyObject *)__pyx_n_s__wb));
          __Pyx_XDECREF(((PyObject *)__pyx_v_mode));
          __pyx_v_mode = __pyx_n_s__wb;
          goto __pyx_L7;
        }
        /*else*/ {
 423:                     else:
 424:                         mode = "ab+"
          /* "water_algorithm_cython.pyx":424
 *                         mode = "wb"
 *                     else:
 *                         mode = "ab+"             # <<<<<<<<<<<<<<
 *                     continue_sequence = True
 *                     print "Processor number %i writes %i results" % (j, len(water_orientations))
 */
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_57));
          __Pyx_XDECREF(((PyObject *)__pyx_v_mode));
          __pyx_v_mode = __pyx_kp_s_57;
        }
        __pyx_L7:;
 425:                     continue_sequence = True
        /* "water_algorithm_cython.pyx":425
 *                     else:
 *                         mode = "ab+"
 *                     continue_sequence = True             # <<<<<<<<<<<<<<
 *                     print "Processor number %i writes %i results" % (j, len(water_orientations))
 *                     ar_file = open(self.get_folder()+"allresults.txt", mode)
 */
        __pyx_v_continue_sequence = 1;
 426:                     print "Processor number %i writes %i results" % (j, len(water_orientations))
        /* "water_algorithm_cython.pyx":426
 *                         mode = "ab+"
 *                     continue_sequence = True
 *                     print "Processor number %i writes %i results" % (j, len(water_orientations))             # <<<<<<<<<<<<<<
 *                     ar_file = open(self.get_folder()+"allresults.txt", mode)
 *                     self.write_water_orientations(ar_file, water_orientations)
 */
        __pyx_t_3 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyObject_Length(__pyx_v_water_orientations); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_3 = 0;
        __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_58), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
 427:                     ar_file = open(self.get_folder()+"allresults.txt", mode)
        /* "water_algorithm_cython.pyx":427
 *                     continue_sequence = True
 *                     print "Processor number %i writes %i results" % (j, len(water_orientations))
 *                     ar_file = open(self.get_folder()+"allresults.txt", mode)             # <<<<<<<<<<<<<<
 *                     self.write_water_orientations(ar_file, water_orientations)
 *                     ar_file.close()
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_s_20)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __Pyx_INCREF(((PyObject *)__pyx_v_mode));
        PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_mode));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_mode));
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_v_ar_file);
        __pyx_v_ar_file = __pyx_t_6;
        __pyx_t_6 = 0;
 428:                     self.write_water_orientations(ar_file, water_orientations)
        /* "water_algorithm_cython.pyx":428
 *                     print "Processor number %i writes %i results" % (j, len(water_orientations))
 *                     ar_file = open(self.get_folder()+"allresults.txt", mode)
 *                     self.write_water_orientations(ar_file, water_orientations)             # <<<<<<<<<<<<<<
 *                     ar_file.close()
 *                 else:
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_59); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_ar_file);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_ar_file);
        __Pyx_GIVEREF(__pyx_v_ar_file);
        __Pyx_INCREF(__pyx_v_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_water_orientations);
        __Pyx_GIVEREF(__pyx_v_water_orientations);
        __pyx_t_3 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 429:                     ar_file.close()
        /* "water_algorithm_cython.pyx":429
 *                     ar_file = open(self.get_folder()+"allresults.txt", mode)
 *                     self.write_water_orientations(ar_file, water_orientations)
 *                     ar_file.close()             # <<<<<<<<<<<<<<
 *                 else:
 *                     continue_sequence = True
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar_file, __pyx_n_s__close); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L6;
      }
      /*else*/ {
 430:                 else:
 431:                     continue_sequence = True
        /* "water_algorithm_cython.pyx":431
 *                     ar_file.close()
 *                 else:
 *                     continue_sequence = True             # <<<<<<<<<<<<<<
 *                 cs = comm.allgather(continue_sequence)
 *         else:
 */
        __pyx_v_continue_sequence = 1;
      }
      __pyx_L6:;
 432:                 cs = comm.allgather(continue_sequence)
      /* "water_algorithm_cython.pyx":432
 *                 else:
 *                     continue_sequence = True
 *                 cs = comm.allgather(continue_sequence)             # <<<<<<<<<<<<<<
 *         else:
 *             if rank == 0:
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__allgather); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_continue_sequence); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_v_cs);
      __pyx_v_cs = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    goto __pyx_L3;
  }
  /*else*/ {
 433:         else:
 434:             if rank == 0:
    /* "water_algorithm_cython.pyx":434
 *                 cs = comm.allgather(continue_sequence)
 *         else:
 *             if rank == 0:             # <<<<<<<<<<<<<<
 *                 folder = self.get_folder()
 *                 if self.intermediate_saves is not None and i in self.intermediate_saves:
 */
    __pyx_t_1 = (rank == 0);
    if (__pyx_t_1) {
 435:                 folder = self.get_folder()
      /* "water_algorithm_cython.pyx":435
 *         else:
 *             if rank == 0:
 *                 folder = self.get_folder()             # <<<<<<<<<<<<<<
 *                 if self.intermediate_saves is not None and i in self.intermediate_saves:
 *                     np.savetxt(folder+"intermediate_%i.txt" % (i), water_orientations)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_folder = __pyx_t_6;
      __pyx_t_6 = 0;
 436:                 if self.intermediate_saves is not None and i in self.intermediate_saves:
      /* "water_algorithm_cython.pyx":436
 *             if rank == 0:
 *                 folder = self.get_folder()
 *                 if self.intermediate_saves is not None and i in self.intermediate_saves:             # <<<<<<<<<<<<<<
 *                     np.savetxt(folder+"intermediate_%i.txt" % (i), water_orientations)
 * 
 */
      __pyx_t_1 = (((PyObject *)__pyx_v_self->intermediate_saves) != Py_None);
      if (__pyx_t_1) {
        __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = (__Pyx_PySequence_Contains(__pyx_t_6, ((PyObject *)__pyx_v_self->intermediate_saves), Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_2 = __pyx_t_8;
      } else {
        __pyx_t_2 = __pyx_t_1;
      }
      if (__pyx_t_2) {
 437:                     np.savetxt(folder+"intermediate_%i.txt" % (i), water_orientations)
        /* "water_algorithm_cython.pyx":437
 *                 folder = self.get_folder()
 *                 if self.intermediate_saves is not None and i in self.intermediate_saves:
 *                     np.savetxt(folder+"intermediate_%i.txt" % (i), water_orientations)             # <<<<<<<<<<<<<<
 * 
 *                 if self.group_saves is not None and group_number != -1 and i in self.group_saves:
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__savetxt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_60), __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_v_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_water_orientations);
        __Pyx_GIVEREF(__pyx_v_water_orientations);
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L9;
      }
      __pyx_L9:;
 438: 
 439:                 if self.group_saves is not None and group_number != -1 and i in self.group_saves:
      /* "water_algorithm_cython.pyx":439
 *                     np.savetxt(folder+"intermediate_%i.txt" % (i), water_orientations)
 * 
 *                 if self.group_saves is not None and group_number != -1 and i in self.group_saves:             # <<<<<<<<<<<<<<
 *                     np.savetxt(folder+"group_%i_%i.txt" % (i, group_number), water_orientations)
 * 
 */
      __pyx_t_2 = (((PyObject *)__pyx_v_self->group_saves) != Py_None);
      if (__pyx_t_2) {
        __pyx_t_6 = PyObject_RichCompare(__pyx_v_group_number, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_1) {
          __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_8 = (__Pyx_PySequence_Contains(__pyx_t_6, ((PyObject *)__pyx_v_self->group_saves), Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_11 = __pyx_t_8;
        } else {
          __pyx_t_11 = __pyx_t_1;
        }
        __pyx_t_1 = __pyx_t_11;
      } else {
        __pyx_t_1 = __pyx_t_2;
      }
      if (__pyx_t_1) {
 440:                     np.savetxt(folder+"group_%i_%i.txt" % (i, group_number), water_orientations)
        /* "water_algorithm_cython.pyx":440
 * 
 *                 if self.group_saves is not None and group_number != -1 and i in self.group_saves:
 *                     np.savetxt(folder+"group_%i_%i.txt" % (i, group_number), water_orientations)             # <<<<<<<<<<<<<<
 * 
 *                 elif not group_save and i == order[len(order)-1]:
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__savetxt); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_v_group_number);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_group_number);
        __Pyx_GIVEREF(__pyx_v_group_number);
        __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_61), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_water_orientations);
        __Pyx_GIVEREF(__pyx_v_water_orientations);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L10;
      }
 441: 
 442:                 elif not group_save and i == order[len(order)-1]:
      /* "water_algorithm_cython.pyx":442
 *                     np.savetxt(folder+"group_%i_%i.txt" % (i, group_number), water_orientations)
 * 
 *                 elif not group_save and i == order[len(order)-1]:             # <<<<<<<<<<<<<<
 *                     if self.write_geometries:
 *                         if not os.path.exists(folder+"alkuperaiset/"):
 */
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_group_save); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = (!__pyx_t_1);
      if (__pyx_t_2) {
        __pyx_t_3 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyObject_Length(__pyx_v_order); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = (__pyx_t_4 - 1);
        __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_order, __pyx_t_5, sizeof(Py_ssize_t), PyInt_FromSsize_t, 0, 0, 0); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_11 = __pyx_t_1;
      } else {
        __pyx_t_11 = __pyx_t_2;
      }
      if (__pyx_t_11) {
 443:                     if self.write_geometries:
        /* "water_algorithm_cython.pyx":443
 * 
 *                 elif not group_save and i == order[len(order)-1]:
 *                     if self.write_geometries:             # <<<<<<<<<<<<<<
 *                         if not os.path.exists(folder+"alkuperaiset/"):
 *                             os.makedirs(folder+"alkuperaiset/")
 */
        __pyx_t_11 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->write_geometries)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (__pyx_t_11) {
 444:                         if not os.path.exists(folder+"alkuperaiset/"):
          /* "water_algorithm_cython.pyx":444
 *                 elif not group_save and i == order[len(order)-1]:
 *                     if self.write_geometries:
 *                         if not os.path.exists(folder+"alkuperaiset/"):             # <<<<<<<<<<<<<<
 *                             os.makedirs(folder+"alkuperaiset/")
 *                         write_results_to_file(self,  self.oxygen_coordinates, water_orientations, self.cell,  self.nearest_neighbors_nos,  folder=folder+"alkuperaiset/")
 */
          __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__exists); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_62)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_t_6 = 0;
          __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_2 = (!__pyx_t_11);
          if (__pyx_t_2) {
 445:                             os.makedirs(folder+"alkuperaiset/")
            /* "water_algorithm_cython.pyx":445
 *                     if self.write_geometries:
 *                         if not os.path.exists(folder+"alkuperaiset/"):
 *                             os.makedirs(folder+"alkuperaiset/")             # <<<<<<<<<<<<<<
 *                         write_results_to_file(self,  self.oxygen_coordinates, water_orientations, self.cell,  self.nearest_neighbors_nos,  folder=folder+"alkuperaiset/")
 *                     np.savetxt(folder+"allresults.txt", water_orientations)
 */
            __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__makedirs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_6 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_62)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_7);
            PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;
            __pyx_t_6 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            goto __pyx_L12;
          }
          __pyx_L12:;
 446:                         write_results_to_file(self,  self.oxygen_coordinates, water_orientations, self.cell,  self.nearest_neighbors_nos,  folder=folder+"alkuperaiset/")
          /* "water_algorithm_cython.pyx":446
 *                         if not os.path.exists(folder+"alkuperaiset/"):
 *                             os.makedirs(folder+"alkuperaiset/")
 *                         write_results_to_file(self,  self.oxygen_coordinates, water_orientations, self.cell,  self.nearest_neighbors_nos,  folder=folder+"alkuperaiset/")             # <<<<<<<<<<<<<<
 *                     np.savetxt(folder+"allresults.txt", water_orientations)
 * 
 */
          __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_46); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_INCREF(((PyObject *)__pyx_v_self));
          PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
          __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
          PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self->oxygen_coordinates));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
          __Pyx_INCREF(__pyx_v_water_orientations);
          PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_water_orientations);
          __Pyx_GIVEREF(__pyx_v_water_orientations);
          __Pyx_INCREF(__pyx_v_self->cell);
          PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->cell);
          __Pyx_GIVEREF(__pyx_v_self->cell);
          PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_7 = 0;
          __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
          __pyx_t_12 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_62)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__folder), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;
 447:                     np.savetxt(folder+"allresults.txt", water_orientations)
        /* "water_algorithm_cython.pyx":447
 *                             os.makedirs(folder+"alkuperaiset/")
 *                         write_results_to_file(self,  self.oxygen_coordinates, water_orientations, self.cell,  self.nearest_neighbors_nos,  folder=folder+"alkuperaiset/")
 *                     np.savetxt(folder+"allresults.txt", water_orientations)             # <<<<<<<<<<<<<<
 * 
 *     def write_water_orientations(self, target_file, water_orientations):
 */
        __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__savetxt); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = PyNumber_Add(__pyx_v_folder, ((PyObject *)__pyx_kp_s_20)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_v_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_water_orientations);
        __Pyx_GIVEREF(__pyx_v_water_orientations);
        __pyx_t_12 = 0;
        __pyx_t_12 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L10;
      }
      __pyx_L10:;
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.save_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_mode);
  __Pyx_XDECREF(__pyx_v_ar_file);
  __Pyx_XDECREF(__pyx_v_cs);
  __Pyx_XDECREF(__pyx_v_folder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_31write_water_orientations(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_31write_water_orientations(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_target_file = 0;
  PyObject *__pyx_v_water_orientations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_water_orientations (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__target_file,&__pyx_n_s__water_orientations,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__target_file)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_water_orientations", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_water_orientations") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_target_file = values[0];
    __pyx_v_water_orientations = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_water_orientations", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write_water_orientations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_30write_water_orientations(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_target_file, __pyx_v_water_orientations);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 448: 
 449:     def write_water_orientations(self, target_file, water_orientations):
/* "water_algorithm_cython.pyx":449
 *                     np.savetxt(folder+"allresults.txt", water_orientations)
 * 
 *     def write_water_orientations(self, target_file, water_orientations):             # <<<<<<<<<<<<<<
 *         for wo in water_orientations:
 *             wo_str = ""
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_30write_water_orientations(CYTHON_UNUSED struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_target_file, PyObject *__pyx_v_water_orientations) {
  PyObject *__pyx_v_wo = NULL;
  PyObject *__pyx_v_wo_str = NULL;
  PyObject *__pyx_v_water_orientation = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_water_orientations", 0);
 450:         for wo in water_orientations:
  /* "water_algorithm_cython.pyx":450
 * 
 *     def write_water_orientations(self, target_file, water_orientations):
 *         for wo in water_orientations:             # <<<<<<<<<<<<<<
 *             wo_str = ""
 *             for water_orientation in wo:
 */
  if (PyList_CheckExact(__pyx_v_water_orientations) || PyTuple_CheckExact(__pyx_v_water_orientations)) {
    __pyx_t_1 = __pyx_v_water_orientations; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_water_orientations); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_wo);
    __pyx_v_wo = __pyx_t_4;
    __pyx_t_4 = 0;
 451:             wo_str = ""
    /* "water_algorithm_cython.pyx":451
 *     def write_water_orientations(self, target_file, water_orientations):
 *         for wo in water_orientations:
 *             wo_str = ""             # <<<<<<<<<<<<<<
 *             for water_orientation in wo:
 *                 wo_str += "%i " % water_orientation
 */
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
    __Pyx_XDECREF(((PyObject *)__pyx_v_wo_str));
    __pyx_v_wo_str = __pyx_kp_s_1;
 452:             for water_orientation in wo:
    /* "water_algorithm_cython.pyx":452
 *         for wo in water_orientations:
 *             wo_str = ""
 *             for water_orientation in wo:             # <<<<<<<<<<<<<<
 *                 wo_str += "%i " % water_orientation
 *             wo_str += "\n"
 */
    if (PyList_CheckExact(__pyx_v_wo) || PyTuple_CheckExact(__pyx_v_wo)) {
      __pyx_t_4 = __pyx_v_wo; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_wo); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_7 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_7)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF(__pyx_v_water_orientation);
      __pyx_v_water_orientation = __pyx_t_7;
      __pyx_t_7 = 0;
 453:                 wo_str += "%i " % water_orientation
      /* "water_algorithm_cython.pyx":453
 *             wo_str = ""
 *             for water_orientation in wo:
 *                 wo_str += "%i " % water_orientation             # <<<<<<<<<<<<<<
 *             wo_str += "\n"
 *             target_file.write(wo_str)
 */
      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_63), __pyx_v_water_orientation); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_wo_str), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_wo_str));
      __pyx_v_wo_str = ((PyObject*)__pyx_t_8);
      __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 454:             wo_str += "\n"
    /* "water_algorithm_cython.pyx":454
 *             for water_orientation in wo:
 *                 wo_str += "%i " % water_orientation
 *             wo_str += "\n"             # <<<<<<<<<<<<<<
 *             target_file.write(wo_str)
 * 
 */
    __pyx_t_4 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_wo_str), ((PyObject *)__pyx_kp_s_64)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(((PyObject *)__pyx_v_wo_str));
    __pyx_v_wo_str = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 455:             target_file.write(wo_str)
    /* "water_algorithm_cython.pyx":455
 *                 wo_str += "%i " % water_orientation
 *             wo_str += "\n"
 *             target_file.write(wo_str)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_target_file, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(((PyObject *)__pyx_v_wo_str));
    PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_wo_str));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_wo_str));
    __pyx_t_7 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write_water_orientations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wo);
  __Pyx_XDECREF(__pyx_v_wo_str);
  __Pyx_XDECREF(__pyx_v_water_orientation);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 456: 
 457: 
 458: 
 459: 
 460:     cdef public np.ndarray[DTYPE2_t, ndim=2] perform_2(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations, unsigned char i, np.ndarray[DTYPE_t, ndim=1] order, np.ndarray[DTYPE_t, ndim=1] do_symmetry_check, signed char group, signed char invariant_level, list self_symmetry_groups):
/* "water_algorithm_cython.pyx":460
 * 
 * 
 *     cdef public np.ndarray[DTYPE2_t, ndim=2] perform_2(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations, unsigned char i, np.ndarray[DTYPE_t, ndim=1] order, np.ndarray[DTYPE_t, ndim=1] do_symmetry_check, signed char group, signed char invariant_level, list self_symmetry_groups):             # <<<<<<<<<<<<<<
 *         """
 *             The main method in the performing of the enumeration of proton configurations. Is an recursive method.
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_perform_2(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyArrayObject *__pyx_v_water_orientations, unsigned char __pyx_v_i, PyArrayObject *__pyx_v_order, PyArrayObject *__pyx_v_do_symmetry_check, signed char __pyx_v_group, signed char __pyx_v_invariant_level, PyObject *__pyx_v_self_symmetry_groups) {
  __Pyx_memviewslice __pyx_v_nearest_neighbors_nos = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_nn = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_new_water_orientations = 0;
  int __pyx_v_discarded;
  int __pyx_v_l;
  PyObject *__pyx_v_symmetry_operations = 0;
  PyObject *__pyx_v_original_symmetry_operations = 0;
  float __pyx_v_portion;
  int __pyx_v_save_self_symmetry_groups;
  int __pyx_v_init;
  __Pyx_memviewslice __pyx_v_possible_combinations = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_all_symmetries_found;
  PyObject *__pyx_v_s = NULL;
  int __pyx_v_result_group_count;
  long __pyx_v_number;
  PyObject *__pyx_v_n = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_do_symmetry_check;
  __Pyx_Buffer __pyx_pybuffer_do_symmetry_check;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_new_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_new_water_orientations;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_order;
  __Pyx_Buffer __pyx_pybuffer_order;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("perform_2", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_water_orientations);
  __Pyx_INCREF((PyObject *)__pyx_v_order);
  __Pyx_INCREF((PyObject *)__pyx_v_do_symmetry_check);
  __Pyx_INCREF(__pyx_v_self_symmetry_groups);
  __pyx_pybuffer_new_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_new_water_orientations.refcount = 0;
  __pyx_pybuffernd_new_water_orientations.data = NULL;
  __pyx_pybuffernd_new_water_orientations.rcbuffer = &__pyx_pybuffer_new_water_orientations;
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
  __pyx_pybuffer_order.pybuffer.buf = NULL;
  __pyx_pybuffer_order.refcount = 0;
  __pyx_pybuffernd_order.data = NULL;
  __pyx_pybuffernd_order.rcbuffer = &__pyx_pybuffer_order;
  __pyx_pybuffer_do_symmetry_check.pybuffer.buf = NULL;
  __pyx_pybuffer_do_symmetry_check.refcount = 0;
  __pyx_pybuffernd_do_symmetry_check.data = NULL;
  __pyx_pybuffernd_do_symmetry_check.rcbuffer = &__pyx_pybuffer_do_symmetry_check;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_v_order, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_order.diminfo[0].strides = __pyx_pybuffernd_order.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_order.diminfo[0].shape = __pyx_pybuffernd_order.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer, (PyObject*)__pyx_v_do_symmetry_check, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_do_symmetry_check.diminfo[0].strides = __pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_do_symmetry_check.diminfo[0].shape = __pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer.shape[0];
 461:         """
 462:             The main method in the performing of the enumeration of proton configurations. Is an recursive method.
 463:             Parameters:
 464:                 water_orientations  : the water orientations of previous step, can be None at the first step
 465:                 i                   : the number of molecule handled
 466:                 order               : the order at which the molecules are handled
 467:                 do_symmetry_check   : boolean array (1 or 0) that states at which molecules the symmetry is checked. Defaults to 1 for all if None is given
 468:                 group               : the number of the group handled. Only needed if starting from middle of the process
 469:                 invariant_level     : the depth of the invariants used
 470:                 self_symmetry_groups: the self symmetry groups found on previous iteration
 471: 
 472:             Returns all possible water configurations for the given oxygen raft
 473:         """
 474:         self.print_time_stats()
  /* "water_algorithm_cython.pyx":474
 *             Returns all possible water configurations for the given oxygen raft
 *         """
 *         self.print_time_stats()             # <<<<<<<<<<<<<<
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         cdef DTYPE_t[::1] nn = nearest_neighbors_nos[0, i]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__print_time_stats); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 475:         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
  /* "water_algorithm_cython.pyx":475
 *         """
 *         self.print_time_stats()
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos             # <<<<<<<<<<<<<<
 *         cdef DTYPE_t[::1] nn = nearest_neighbors_nos[0, i]
 *         cdef np.ndarray[DTYPE2_t, ndim=2] new_water_orientations
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_2);
  if (unlikely(!__pyx_t_3.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_nearest_neighbors_nos = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
 476:         cdef DTYPE_t[::1] nn = nearest_neighbors_nos[0, i]
  /* "water_algorithm_cython.pyx":476
 *         self.print_time_stats()
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         cdef DTYPE_t[::1] nn = nearest_neighbors_nos[0, i]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE2_t, ndim=2] new_water_orientations
 *         cdef int discarded, l
 */
  __pyx_t_5 = -1;
  __pyx_t_4.data = __pyx_v_nearest_neighbors_nos.data;
  __pyx_t_4.memview = __pyx_v_nearest_neighbors_nos.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_4, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_4.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

{
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[1];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[1];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_4.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_4.shape[0] = __pyx_v_nearest_neighbors_nos.shape[2];
__pyx_t_4.strides[0] = __pyx_v_nearest_neighbors_nos.strides[2];
    __pyx_t_4.suboffsets[0] = -1;

__pyx_v_nn = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 477:         cdef np.ndarray[DTYPE2_t, ndim=2] new_water_orientations
 478:         cdef int discarded, l
 479:         cdef list symmetry_operations, original_symmetry_operations
 480:         cdef float portion
 481:         cdef bint save_self_symmetry_groups, init
 482:         cdef SymmetryOperation so
 483:         cdef DTYPE_t [:, :, ::1] possible_combinations = self.calculate_possible_combinations(i)
  /* "water_algorithm_cython.pyx":483
 *         cdef bint save_self_symmetry_groups, init
 *         cdef SymmetryOperation so
 *         cdef DTYPE_t [:, :, ::1] possible_combinations = self.calculate_possible_combinations(i)             # <<<<<<<<<<<<<<
 *         self.possible_combinations = possible_combinations
 *         # Have all symmetryoperations been 'found' before. i.e., have all symmetry operations had
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_65); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_1);
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_possible_combinations = __pyx_t_7;
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
 484:         self.possible_combinations = possible_combinations
  /* "water_algorithm_cython.pyx":484
 *         cdef SymmetryOperation so
 *         cdef DTYPE_t [:, :, ::1] possible_combinations = self.calculate_possible_combinations(i)
 *         self.possible_combinations = possible_combinations             # <<<<<<<<<<<<<<
 *         # Have all symmetryoperations been 'found' before. i.e., have all symmetry operations had
 *         #  complete sub symmetries.
 */
  __PYX_XDEC_MEMVIEW(&__pyx_v_self->possible_combinations, 0);
  __PYX_INC_MEMVIEW(&__pyx_v_possible_combinations, 0);
  __pyx_v_self->possible_combinations = __pyx_v_possible_combinations;
 485:         # Have all symmetryoperations been 'found' before. i.e., have all symmetry operations had
 486:         #  complete sub symmetries.
 487:         cdef bint all_symmetries_found = all_found(self.symmetry_operations)
  /* "water_algorithm_cython.pyx":487
 *         # Have all symmetryoperations been 'found' before. i.e., have all symmetry operations had
 *         #  complete sub symmetries.
 *         cdef bint all_symmetries_found = all_found(self.symmetry_operations)             # <<<<<<<<<<<<<<
 *         if order == None:
 *             order = np.arange(0, self.N, 1, dtype=DTYPE)
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->symmetry_operations);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_all_symmetries_found = __pyx_f_10symmetries_25symmetry_operation_cython_all_found(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 488:         if order == None:
  /* "water_algorithm_cython.pyx":488
 *         #  complete sub symmetries.
 *         cdef bint all_symmetries_found = all_found(self.symmetry_operations)
 *         if order == None:             # <<<<<<<<<<<<<<
 *             order = np.arange(0, self.N, 1, dtype=DTYPE)
 *         if do_symmetry_check == None:
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_order), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_8) {
 489:             order = np.arange(0, self.N, 1, dtype=DTYPE)
    /* "water_algorithm_cython.pyx":489
 *         cdef bint all_symmetries_found = all_found(self.symmetry_operations)
 *         if order == None:
 *             order = np.arange(0, self.N, 1, dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         if do_symmetry_check == None:
 *             do_symmetry_check = np.ones(self.N, dtype=DTYPE)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__arange); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_order.rcbuffer->pybuffer, (PyObject*)__pyx_v_order, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
      }
      __pyx_pybuffernd_order.diminfo[0].strides = __pyx_pybuffernd_order.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_order.diminfo[0].shape = __pyx_pybuffernd_order.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_order));
    __pyx_v_order = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 490:         if do_symmetry_check == None:
  /* "water_algorithm_cython.pyx":490
 *         if order == None:
 *             order = np.arange(0, self.N, 1, dtype=DTYPE)
 *         if do_symmetry_check == None:             # <<<<<<<<<<<<<<
 *             do_symmetry_check = np.ones(self.N, dtype=DTYPE)
 *         if i == None:
 */
  __pyx_t_9 = PyObject_RichCompare(((PyObject *)__pyx_v_do_symmetry_check), Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_8) {
 491:             do_symmetry_check = np.ones(self.N, dtype=DTYPE)
    /* "water_algorithm_cython.pyx":491
 *             order = np.arange(0, self.N, 1, dtype=DTYPE)
 *         if do_symmetry_check == None:
 *             do_symmetry_check = np.ones(self.N, dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         if i == None:
 *             i = order[0]
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__ones); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__dtype), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = ((PyArrayObject *)__pyx_t_6);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer, (PyObject*)__pyx_v_do_symmetry_check, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
      }
      __pyx_pybuffernd_do_symmetry_check.diminfo[0].strides = __pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_do_symmetry_check.diminfo[0].shape = __pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_do_symmetry_check));
    __pyx_v_do_symmetry_check = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;
 492:         if i == None:
  /* "water_algorithm_cython.pyx":492
 *         if do_symmetry_check == None:
 *             do_symmetry_check = np.ones(self.N, dtype=DTYPE)
 *         if i == None:             # <<<<<<<<<<<<<<
 *             i = order[0]
 *         # Loaded from i certain state
 */
  __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyObject_RichCompare(__pyx_t_6, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_8) {
 493:             i = order[0]
    /* "water_algorithm_cython.pyx":493
 *             do_symmetry_check = np.ones(self.N, dtype=DTYPE)
 *         if i == None:
 *             i = order[0]             # <<<<<<<<<<<<<<
 *         # Loaded from i certain state
 *         if i != order[0] and group == None and water_orientations == []:
 */
    __pyx_t_15 = 0;
    __pyx_v_i = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_order.diminfo[0].strides));
    goto __pyx_L5;
  }
  __pyx_L5:;
 494:         # Loaded from i certain state
 495:         if i != order[0] and group == None and water_orientations == []:
  /* "water_algorithm_cython.pyx":495
 *             i = order[0]
 *         # Loaded from i certain state
 *         if i != order[0] and group == None and water_orientations == []:             # <<<<<<<<<<<<<<
 *             if rank == 0:
 *                 print self.get_folder()+"intermediate_%i.txt" % i
 */
  __pyx_t_16 = 0;
  __pyx_t_8 = (__pyx_v_i != (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_order.diminfo[0].strides)));
  if (__pyx_t_8) {
    __pyx_t_9 = PyInt_FromLong(__pyx_v_group); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_9, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_17) {
      __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyObject_RichCompare(((PyObject *)__pyx_v_water_orientations), ((PyObject *)__pyx_t_6), Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_18 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_19 = __pyx_t_18;
    } else {
      __pyx_t_19 = __pyx_t_17;
    }
    __pyx_t_17 = __pyx_t_19;
  } else {
    __pyx_t_17 = __pyx_t_8;
  }
  if (__pyx_t_17) {
 496:             if rank == 0:
    /* "water_algorithm_cython.pyx":496
 *         # Loaded from i certain state
 *         if i != order[0] and group == None and water_orientations == []:
 *             if rank == 0:             # <<<<<<<<<<<<<<
 *                 print self.get_folder()+"intermediate_%i.txt" % i
 *                 new_water_orientations = np.loadtxt(self.get_folder()+"intermediate_%i.txt" % i)
 */
    __pyx_t_17 = (rank == 0);
    if (__pyx_t_17) {
 497:                 print self.get_folder()+"intermediate_%i.txt" % i
      /* "water_algorithm_cython.pyx":497
 *         if i != order[0] and group == None and water_orientations == []:
 *             if rank == 0:
 *                 print self.get_folder()+"intermediate_%i.txt" % i             # <<<<<<<<<<<<<<
 *                 new_water_orientations = np.loadtxt(self.get_folder()+"intermediate_%i.txt" % i)
 *                 new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_60), __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 498:                 new_water_orientations = np.loadtxt(self.get_folder()+"intermediate_%i.txt" % i)
      /* "water_algorithm_cython.pyx":498
 *             if rank == 0:
 *                 print self.get_folder()+"intermediate_%i.txt" % i
 *                 new_water_orientations = np.loadtxt(self.get_folder()+"intermediate_%i.txt" % i)             # <<<<<<<<<<<<<<
 *                 new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
 *             else:
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__loadtxt); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_60), __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_20 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_20 = 0;
      __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_9);
      __pyx_t_9 = 0;
 499:                 new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
      /* "water_algorithm_cython.pyx":499
 *                 print self.get_folder()+"intermediate_%i.txt" % i
 *                 new_water_orientations = np.loadtxt(self.get_folder()+"intermediate_%i.txt" % i)
 *                 new_water_orientations = np.array(new_water_orientations, dtype=np.int8)             # <<<<<<<<<<<<<<
 *             else:
 *                 new_water_orientations = None
 */
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_new_water_orientations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__int8); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_21) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_21) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_21, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_20 = ((PyArrayObject *)__pyx_t_21);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
          }
        }
        __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_20 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
      __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_21);
      __pyx_t_21 = 0;
      goto __pyx_L7;
    }
    /*else*/ {
 500:             else:
 501:                 new_water_orientations = None
      /* "water_algorithm_cython.pyx":501
 *                 new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
 *             else:
 *                 new_water_orientations = None             # <<<<<<<<<<<<<<
 *             new_water_orientations = comm.bcast(new_water_orientations, root = 0)
 *         else:
 */
      __pyx_t_20 = ((PyArrayObject *)Py_None);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_20 = 0;
      __Pyx_INCREF(Py_None);
      __pyx_v_new_water_orientations = ((PyArrayObject *)Py_None);
    }
    __pyx_L7:;
 502:             new_water_orientations = comm.bcast(new_water_orientations, root = 0)
    /* "water_algorithm_cython.pyx":502
 *             else:
 *                 new_water_orientations = None
 *             new_water_orientations = comm.bcast(new_water_orientations, root = 0)             # <<<<<<<<<<<<<<
 *         else:
 *             print_parallel("Handling molecule number %i." % i, self.logfile)
 */
    __pyx_t_21 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_new_water_orientations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
      }
      __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_20 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
    __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L6;
  }
  /*else*/ {
 503:         else:
 504:             print_parallel("Handling molecule number %i." % i, self.logfile)
    /* "water_algorithm_cython.pyx":504
 *             new_water_orientations = comm.bcast(new_water_orientations, root = 0)
 *         else:
 *             print_parallel("Handling molecule number %i." % i, self.logfile)             # <<<<<<<<<<<<<<
 *             print_("Handling molecule number %i." % i, self.logfile)
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_66), __pyx_t_9); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 505:             print_("Handling molecule number %i." % i, self.logfile)
    /* "water_algorithm_cython.pyx":505
 *         else:
 *             print_parallel("Handling molecule number %i." % i, self.logfile)
 *             print_("Handling molecule number %i." % i, self.logfile)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_66), __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 506: 
 507: 
 508:             if group == None or group == -1:
    /* "water_algorithm_cython.pyx":508
 * 
 * 
 *             if group == None or group == -1:             # <<<<<<<<<<<<<<
 *                 # Do the iteration
 *                 #  - First handle charges
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_group); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyObject_RichCompare(__pyx_t_1, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!__pyx_t_17) {
      __pyx_t_8 = (__pyx_v_group == -1);
      __pyx_t_19 = __pyx_t_8;
    } else {
      __pyx_t_19 = __pyx_t_17;
    }
    if (__pyx_t_19) {
 509:                 # Do the iteration
 510:                 #  - First handle charges
 511:                 if (self.charge != 0 or self.dissosiation_count != 0) and i == order[0]:
      /* "water_algorithm_cython.pyx":511
 *                 # Do the iteration
 *                 #  - First handle charges
 *                 if (self.charge != 0 or self.dissosiation_count != 0) and i == order[0]:             # <<<<<<<<<<<<<<
 *                     water_orientations = self.handle_charges()
 *                     self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
 */
      __pyx_t_19 = (__pyx_v_self->charge != 0);
      if (!__pyx_t_19) {
        __pyx_t_17 = (__pyx_v_self->dissosiation_count != 0);
        __pyx_t_8 = __pyx_t_17;
      } else {
        __pyx_t_8 = __pyx_t_19;
      }
      if (__pyx_t_8) {
        __pyx_t_22 = 0;
        __pyx_t_19 = (__pyx_v_i == (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_order.diminfo[0].strides)));
        __pyx_t_17 = __pyx_t_19;
      } else {
        __pyx_t_17 = __pyx_t_8;
      }
      if (__pyx_t_17) {
 512:                     water_orientations = self.handle_charges()
        /* "water_algorithm_cython.pyx":512
 *                 #  - First handle charges
 *                 if (self.charge != 0 or self.dissosiation_count != 0) and i == order[0]:
 *                     water_orientations = self.handle_charges()             # <<<<<<<<<<<<<<
 *                     self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
 *                 new_water_orientations = np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__handle_charges); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_1 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_23 = ((PyArrayObject *)__pyx_t_1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            }
          }
          __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_23 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
        __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_1);
        __pyx_t_1 = 0;
 513:                     self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
        /* "water_algorithm_cython.pyx":513
 *                 if (self.charge != 0 or self.dissosiation_count != 0) and i == order[0]:
 *                     water_orientations = self.handle_charges()
 *                     self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)             # <<<<<<<<<<<<<<
 *                 new_water_orientations = np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)
 * 
 */
        if (unlikely(((PyObject *)__pyx_v_self->graph_invariants) == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_1 = __Pyx_PyList_GetSlice(((PyObject *)__pyx_v_self->graph_invariants), __pyx_v_invariant_level, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_1));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_19result_group_cython_ResultGroup)), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        __Pyx_GIVEREF(__pyx_t_1);
        __Pyx_GOTREF(__pyx_v_self->result_group);
        __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
        __pyx_v_self->result_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_1);
        __pyx_t_1 = 0;
        goto __pyx_L9;
      }
      __pyx_L9:;
 514:                 new_water_orientations = np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":514
 *                     water_orientations = self.handle_charges()
 *                     self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
 *                 new_water_orientations = np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 * 
 *                 # handle the actual iteration of the orientations
 */
      __pyx_t_1 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_water_orientations->dimensions[1])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
      __pyx_t_9 = 0;
      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_2), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
          }
        }
        __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
 515: 
 516:                 # handle the actual iteration of the orientations
 517:                 s = time()
      /* "water_algorithm_cython.pyx":517
 * 
 *                 # handle the actual iteration of the orientations
 *                 s = time()             # <<<<<<<<<<<<<<
 *                 discarded = 0
 *                 if water_orientations.shape[0] == 0 and i == order[0]:
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_s = __pyx_t_9;
      __pyx_t_9 = 0;
 518:                 discarded = 0
      /* "water_algorithm_cython.pyx":518
 *                 # handle the actual iteration of the orientations
 *                 s = time()
 *                 discarded = 0             # <<<<<<<<<<<<<<
 *                 if water_orientations.shape[0] == 0 and i == order[0]:
 *                     if rank == 0:
 */
      __pyx_v_discarded = 0;
 519:                 if water_orientations.shape[0] == 0 and i == order[0]:
      /* "water_algorithm_cython.pyx":519
 *                 s = time()
 *                 discarded = 0
 *                 if water_orientations.shape[0] == 0 and i == order[0]:             # <<<<<<<<<<<<<<
 *                     if rank == 0:
 *                         init = True
 */
      __pyx_t_17 = ((__pyx_v_water_orientations->dimensions[0]) == 0);
      if (__pyx_t_17) {
        __pyx_t_24 = 0;
        __pyx_t_8 = (__pyx_v_i == (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_order.diminfo[0].strides)));
        __pyx_t_19 = __pyx_t_8;
      } else {
        __pyx_t_19 = __pyx_t_17;
      }
      if (__pyx_t_19) {
 520:                     if rank == 0:
        /* "water_algorithm_cython.pyx":520
 *                 discarded = 0
 *                 if water_orientations.shape[0] == 0 and i == order[0]:
 *                     if rank == 0:             # <<<<<<<<<<<<<<
 *                         init = True
 *                         new_water_orientations = self.handle_molecule_algorithm_2(i, None, possible_combinations, nn, init, &discarded)
 */
        __pyx_t_19 = (rank == 0);
        if (__pyx_t_19) {
 521:                         init = True
          /* "water_algorithm_cython.pyx":521
 *                 if water_orientations.shape[0] == 0 and i == order[0]:
 *                     if rank == 0:
 *                         init = True             # <<<<<<<<<<<<<<
 *                         new_water_orientations = self.handle_molecule_algorithm_2(i, None, possible_combinations, nn, init, &discarded)
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 */
          __pyx_v_init = 1;
 522:                         new_water_orientations = self.handle_molecule_algorithm_2(i, None, possible_combinations, nn, init, &discarded)
          /* "water_algorithm_cython.pyx":522
 *                     if rank == 0:
 *                         init = True
 *                         new_water_orientations = self.handle_molecule_algorithm_2(i, None, possible_combinations, nn, init, &discarded)             # <<<<<<<<<<<<<<
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 *                 else:
 */
          __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(Py_None);
          if (unlikely(!__pyx_t_25.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_9 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->handle_molecule_algorithm_2(__pyx_v_self, __pyx_v_i, __pyx_t_25, __pyx_v_possible_combinations, __pyx_v_nn, __pyx_v_init, (&__pyx_v_discarded))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
            __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_9), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
            if (unlikely(__pyx_t_5 < 0)) {
              PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
              }
            }
            __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
            if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
          __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_9);
          __pyx_t_9 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;
 523:                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
        /* "water_algorithm_cython.pyx":523
 *                         init = True
 *                         new_water_orientations = self.handle_molecule_algorithm_2(i, None, possible_combinations, nn, init, &discarded)
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)             # <<<<<<<<<<<<<<
 *                 else:
 *                     init = False
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_new_water_orientations));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_21 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        if (!(likely(((__pyx_t_21) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_21, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_20 = ((PyArrayObject *)__pyx_t_21);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_20 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_21);
        __pyx_t_21 = 0;
        goto __pyx_L10;
      }
      /*else*/ {
 524:                 else:
 525:                     init = False
        /* "water_algorithm_cython.pyx":525
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 *                 else:
 *                     init = False             # <<<<<<<<<<<<<<
 *                     if not all_symmetries_found:
 *                         water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
 */
        __pyx_v_init = 0;
 526:                     if not all_symmetries_found:
        /* "water_algorithm_cython.pyx":526
 *                 else:
 *                     init = False
 *                     if not all_symmetries_found:             # <<<<<<<<<<<<<<
 *                         water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
 *                         #print "All symmetries are not found, scattering %i wos" % len(water_orientations)
 */
        __pyx_t_19 = (!__pyx_v_all_symmetries_found);
        if (__pyx_t_19) {
 527:                         water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
          /* "water_algorithm_cython.pyx":527
 *                     init = False
 *                     if not all_symmetries_found:
 *                         water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)             # <<<<<<<<<<<<<<
 *                         #print "All symmetries are not found, scattering %i wos" % len(water_orientations)
 *                     #print "Processor %i handles %i wos" % (rank, len(water_orientations))
 */
          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_21);
          __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = PyInt_FromLong(size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
          PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_water_orientations));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
          PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;
          __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;
          __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_2));
          if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_1 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_t_9), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_23 = ((PyArrayObject *)__pyx_t_1);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
            __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
            if (unlikely(__pyx_t_5 < 0)) {
              PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
              }
            }
            __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
            if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_23 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
          __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_1);
          __pyx_t_1 = 0;
          goto __pyx_L12;
        }
        __pyx_L12:;
 528:                         #print "All symmetries are not found, scattering %i wos" % len(water_orientations)
 529:                     #print "Processor %i handles %i wos" % (rank, len(water_orientations))
 530:                     new_water_orientations = self.handle_molecule_algorithm_2(i, water_orientations, possible_combinations, nn, init, &discarded)
        /* "water_algorithm_cython.pyx":530
 *                         #print "All symmetries are not found, scattering %i wos" % len(water_orientations)
 *                     #print "Processor %i handles %i wos" % (rank, len(water_orientations))
 *                     new_water_orientations = self.handle_molecule_algorithm_2(i, water_orientations, possible_combinations, nn, init, &discarded)             # <<<<<<<<<<<<<<
 * 
 *                     if not all_symmetries_found:
 */
        __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_water_orientations));
        if (unlikely(!__pyx_t_25.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->handle_molecule_algorithm_2(__pyx_v_self, __pyx_v_i, __pyx_t_25, __pyx_v_possible_combinations, __pyx_v_nn, __pyx_v_init, (&__pyx_v_discarded))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_1);
        __pyx_t_1 = 0;
 531: 
 532:                     if not all_symmetries_found:
        /* "water_algorithm_cython.pyx":532
 *                     new_water_orientations = self.handle_molecule_algorithm_2(i, water_orientations, possible_combinations, nn, init, &discarded)
 * 
 *                     if not all_symmetries_found:             # <<<<<<<<<<<<<<
 *                         new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
 *                         #print "All symmetries are not found, gathering %i wos" % len(new_water_orientations)
 */
        __pyx_t_19 = (!__pyx_v_all_symmetries_found);
        if (__pyx_t_19) {
 533:                         new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
          /* "water_algorithm_cython.pyx":533
 * 
 *                     if not all_symmetries_found:
 *                         new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))             # <<<<<<<<<<<<<<
 *                         #print "All symmetries are not found, gathering %i wos" % len(new_water_orientations)
 * 
 */
          __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_67); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__allgather); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
          PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_new_water_orientations));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
          __pyx_t_21 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_21);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_21);
          __Pyx_GIVEREF(__pyx_t_21);
          __pyx_t_21 = 0;
          __pyx_t_21 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_21);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
          if (!(likely(((__pyx_t_21) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_21, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_20 = ((PyArrayObject *)__pyx_t_21);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
            __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
            if (unlikely(__pyx_t_5 < 0)) {
              PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
              }
            }
            __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
            if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_20 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
          __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_21);
          __pyx_t_21 = 0;
          goto __pyx_L13;
        }
        __pyx_L13:;
      }
      __pyx_L10:;
 534:                         #print "All symmetries are not found, gathering %i wos" % len(new_water_orientations)
 535: 
 536:                 discarded = gather_and_sum(discarded)
      /* "water_algorithm_cython.pyx":536
 *                         #print "All symmetries are not found, gathering %i wos" % len(new_water_orientations)
 * 
 *                 discarded = gather_and_sum(discarded)             # <<<<<<<<<<<<<<
 *                 #print_parallel("Discarded %i geometries due to breakage of ice rules. Results %i geometries." % (discarded, new_water_orientations.shape[0]), self.logfile)
 *                 self.iteration_time += time()-s
 */
      __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_sum); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_9 = PyInt_FromLong(__pyx_v_discarded); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_discarded = __pyx_t_5;
 537:                 #print_parallel("Discarded %i geometries due to breakage of ice rules. Results %i geometries." % (discarded, new_water_orientations.shape[0]), self.logfile)
 538:                 self.iteration_time += time()-s
      /* "water_algorithm_cython.pyx":538
 *                 discarded = gather_and_sum(discarded)
 *                 #print_parallel("Discarded %i geometries due to breakage of ice rules. Results %i geometries." % (discarded, new_water_orientations.shape[0]), self.logfile)
 *                 self.iteration_time += time()-s             # <<<<<<<<<<<<<<
 *             else:
 *                 if rank == 0:
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_21 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_Subtract(__pyx_t_21, __pyx_v_s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time, __pyx_t_21) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      goto __pyx_L8;
    }
    /*else*/ {
 539:             else:
 540:                 if rank == 0:
      /* "water_algorithm_cython.pyx":540
 *                 self.iteration_time += time()-s
 *             else:
 *                 if rank == 0:             # <<<<<<<<<<<<<<
 *                     print self.get_folder()+"group_%i_%i.txt" % (i, group)
 *                     new_water_orientations = np.loadtxt(self.get_folder()+"group_%i_%i.txt" % (i, group))
 */
      __pyx_t_19 = (rank == 0);
      if (__pyx_t_19) {
 541:                     print self.get_folder()+"group_%i_%i.txt" % (i, group)
        /* "water_algorithm_cython.pyx":541
 *             else:
 *                 if rank == 0:
 *                     print self.get_folder()+"group_%i_%i.txt" % (i, group)             # <<<<<<<<<<<<<<
 *                     new_water_orientations = np.loadtxt(self.get_folder()+"group_%i_%i.txt" % (i, group))
 *                     new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
 */
        __pyx_t_21 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_1 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __pyx_t_21 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_9 = PyInt_FromLong(__pyx_v_group); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_21);
        __Pyx_GIVEREF(__pyx_t_21);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_21 = 0;
        __pyx_t_9 = 0;
        __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_61), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 542:                     new_water_orientations = np.loadtxt(self.get_folder()+"group_%i_%i.txt" % (i, group))
        /* "water_algorithm_cython.pyx":542
 *                 if rank == 0:
 *                     print self.get_folder()+"group_%i_%i.txt" % (i, group)
 *                     new_water_orientations = np.loadtxt(self.get_folder()+"group_%i_%i.txt" % (i, group))             # <<<<<<<<<<<<<<
 *                     new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
 *                 else:
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__loadtxt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_21 = PyInt_FromLong(__pyx_v_group); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_21);
        __Pyx_GIVEREF(__pyx_t_21);
        __pyx_t_2 = 0;
        __pyx_t_21 = 0;
        __pyx_t_21 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_61), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_21));
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __pyx_t_6 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_t_21)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
        __pyx_t_21 = PyTuple_New(1); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_6 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_21), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_20 = ((PyArrayObject *)__pyx_t_6);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_20 = 0;
        __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_6);
        __pyx_t_6 = 0;
 543:                     new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
        /* "water_algorithm_cython.pyx":543
 *                     print self.get_folder()+"group_%i_%i.txt" % (i, group)
 *                     new_water_orientations = np.loadtxt(self.get_folder()+"group_%i_%i.txt" % (i, group))
 *                     new_water_orientations = np.array(new_water_orientations, dtype=np.int8)             # <<<<<<<<<<<<<<
 *                 else:
 *                     new_water_orientations = None
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__array); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_new_water_orientations));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__int8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_20 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_20 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L14;
      }
      /*else*/ {
 544:                 else:
 545:                     new_water_orientations = None
        /* "water_algorithm_cython.pyx":545
 *                     new_water_orientations = np.array(new_water_orientations, dtype=np.int8)
 *                 else:
 *                     new_water_orientations = None             # <<<<<<<<<<<<<<
 *                 new_water_orientations = comm.bcast(new_water_orientations, root = 0)
 * 
 */
        __pyx_t_20 = ((PyArrayObject *)Py_None);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_20 = 0;
        __Pyx_INCREF(Py_None);
        __pyx_v_new_water_orientations = ((PyArrayObject *)Py_None);
      }
      __pyx_L14:;
 546:                 new_water_orientations = comm.bcast(new_water_orientations, root = 0)
      /* "water_algorithm_cython.pyx":546
 *                 else:
 *                     new_water_orientations = None
 *                 new_water_orientations = comm.bcast(new_water_orientations, root = 0)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_new_water_orientations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_21 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_9), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_21) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_21, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_20 = ((PyArrayObject *)__pyx_t_21);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_20 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
      __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_21);
      __pyx_t_21 = 0;
    }
    __pyx_L8:;
 547: 
 548: 
 549:             s = time()
    /* "water_algorithm_cython.pyx":549
 * 
 * 
 *             s = time()             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_6 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_v_s);
    __pyx_v_s = __pyx_t_6;
    __pyx_t_6 = 0;
 550: 
 551: 
 552:             #Remove the symmetries
 553:             # -First find the symmetries that can be possible, because of molecule changes
 554:             # -And handle the self symmetric groups (water orientations that have a parent that is symmetric with itself)
 555:             # -Remove the symmetry operations that cannot be possible because their parents are not related by these symmetry operations
 556:             # -And finally handle the normal cases
 557:             if do_symmetry_check[i] == 1 and self.graph_invariants is not None:
    /* "water_algorithm_cython.pyx":557
 *             # -Remove the symmetry operations that cannot be possible because their parents are not related by these symmetry operations
 *             # -And finally handle the normal cases
 *             if do_symmetry_check[i] == 1 and self.graph_invariants is not None:             # <<<<<<<<<<<<<<
 *                 self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
 *                 if i == self.order[self.order.shape[0]-1]:
 */
    __pyx_t_26 = __pyx_v_i;
    __pyx_t_19 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_do_symmetry_check.diminfo[0].strides)) == 1);
    if (__pyx_t_19) {
      __pyx_t_17 = (__pyx_v_self->graph_invariants != ((PyObject*)Py_None));
      __pyx_t_8 = __pyx_t_17;
    } else {
      __pyx_t_8 = __pyx_t_19;
    }
    if (__pyx_t_8) {
 558:                 self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
      /* "water_algorithm_cython.pyx":558
 *             # -And finally handle the normal cases
 *             if do_symmetry_check[i] == 1 and self.graph_invariants is not None:
 *                 self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)             # <<<<<<<<<<<<<<
 *                 if i == self.order[self.order.shape[0]-1]:
 *                     save_self_symmetry_groups = False
 */
      if (unlikely(((PyObject *)__pyx_v_self->graph_invariants) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = __Pyx_PyList_GetSlice(((PyObject *)__pyx_v_self->graph_invariants), __pyx_v_invariant_level, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __pyx_t_21 = PyTuple_New(1); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      PyTuple_SET_ITEM(__pyx_t_21, 0, ((PyObject *)__pyx_t_6));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_21), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
      __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_19result_group_cython_ResultGroup)), ((PyObject *)__pyx_t_21), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_v_self->result_group);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
      __pyx_v_self->result_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_6);
      __pyx_t_6 = 0;
 559:                 if i == self.order[self.order.shape[0]-1]:
      /* "water_algorithm_cython.pyx":559
 *             if do_symmetry_check[i] == 1 and self.graph_invariants is not None:
 *                 self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
 *                 if i == self.order[self.order.shape[0]-1]:             # <<<<<<<<<<<<<<
 *                     save_self_symmetry_groups = False
 *                 else:
 */
      __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_27 = ((__pyx_v_self->order->dimensions[0]) - 1);
      __pyx_t_21 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->order), __pyx_t_27, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_21) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_9 = PyObject_RichCompare(__pyx_t_6, __pyx_t_21, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (__pyx_t_8) {
 560:                     save_self_symmetry_groups = False
        /* "water_algorithm_cython.pyx":560
 *                 self.result_group = ResultGroup(list(self.graph_invariants[invariant_level:]),  0)
 *                 if i == self.order[self.order.shape[0]-1]:
 *                     save_self_symmetry_groups = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     save_self_symmetry_groups = self.save_self_symmetry_groups
 */
        __pyx_v_save_self_symmetry_groups = 0;
        goto __pyx_L16;
      }
      /*else*/ {
 561:                 else:
 562:                     save_self_symmetry_groups = self.save_self_symmetry_groups
        /* "water_algorithm_cython.pyx":562
 *                     save_self_symmetry_groups = False
 *                 else:
 *                     save_self_symmetry_groups = self.save_self_symmetry_groups             # <<<<<<<<<<<<<<
 * 
 *                 if rank == 0:
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_68); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_v_save_self_symmetry_groups = __pyx_t_8;
      }
      __pyx_L16:;
 563: 
 564:                 if rank == 0:
      /* "water_algorithm_cython.pyx":564
 *                     save_self_symmetry_groups = self.save_self_symmetry_groups
 * 
 *                 if rank == 0:             # <<<<<<<<<<<<<<
 *                     original_symmetry_operations = do_symmetry_operation_filtering(self.symmetry_operations, i, order)
 *                     """
 */
      __pyx_t_8 = (rank == 0);
      if (__pyx_t_8) {
 565:                     original_symmetry_operations = do_symmetry_operation_filtering(self.symmetry_operations, i, order)
        /* "water_algorithm_cython.pyx":565
 * 
 *                 if rank == 0:
 *                     original_symmetry_operations = do_symmetry_operation_filtering(self.symmetry_operations, i, order)             # <<<<<<<<<<<<<<
 *                     """
 *                     ssi_so = get_sub_symmetry_level_improved(self.symmetry_operations, i, order)
 */
        __pyx_t_9 = ((PyObject *)__pyx_v_self->symmetry_operations);
        __Pyx_INCREF(__pyx_t_9);
        __pyx_t_21 = ((PyObject *)__pyx_f_10symmetries_25symmetry_operation_cython_do_symmetry_operation_filtering(((PyObject*)__pyx_t_9), __pyx_v_i, ((PyArrayObject *)__pyx_v_order))); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_v_original_symmetry_operations = ((PyObject*)__pyx_t_21);
        __pyx_t_21 = 0;
 566:                     """
 567:                     ssi_so = get_sub_symmetry_level_improved(self.symmetry_operations, i, order)
 568:                     for so in ssi_so:
 569:                         print so.molecule_change_matrix, so.sub_symmetry_level
 570:                     print "NFF"
 571:                     for so in self.symmetry_operations:
 572:                         if not so.found_earlier and so.sub_symmetry_level == 0:
 573:                             print so.molecule_change_matrix
 574:                     raw_input()"""
 575:                     symmetry_operations = remove_earlier_found(original_symmetry_operations)
        /* "water_algorithm_cython.pyx":575
 *                             print so.molecule_change_matrix
 *                     raw_input()"""
 *                     symmetry_operations = remove_earlier_found(original_symmetry_operations)             # <<<<<<<<<<<<<<
 *                 else:
 *                     original_symmetry_operations = []
 */
        __pyx_t_21 = ((PyObject *)__pyx_f_10symmetries_25symmetry_operation_cython_remove_earlier_found(__pyx_v_original_symmetry_operations)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_v_symmetry_operations = ((PyObject*)__pyx_t_21);
        __pyx_t_21 = 0;
        goto __pyx_L17;
      }
      /*else*/ {
 576:                 else:
 577:                     original_symmetry_operations = []
        /* "water_algorithm_cython.pyx":577
 *                     symmetry_operations = remove_earlier_found(original_symmetry_operations)
 *                 else:
 *                     original_symmetry_operations = []             # <<<<<<<<<<<<<<
 *                     symmetry_operations = []
 *                 original_symmetry_operations = comm.bcast(original_symmetry_operations, root = 0)
 */
        __pyx_t_21 = PyList_New(0); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_v_original_symmetry_operations = ((PyObject*)__pyx_t_21);
        __pyx_t_21 = 0;
 578:                     symmetry_operations = []
        /* "water_algorithm_cython.pyx":578
 *                 else:
 *                     original_symmetry_operations = []
 *                     symmetry_operations = []             # <<<<<<<<<<<<<<
 *                 original_symmetry_operations = comm.bcast(original_symmetry_operations, root = 0)
 *                 symmetry_operations = comm.bcast(symmetry_operations, root = 0)
 */
        __pyx_t_21 = PyList_New(0); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_v_symmetry_operations = ((PyObject*)__pyx_t_21);
        __pyx_t_21 = 0;
      }
      __pyx_L17:;
 579:                 original_symmetry_operations = comm.bcast(original_symmetry_operations, root = 0)
      /* "water_algorithm_cython.pyx":579
 *                     original_symmetry_operations = []
 *                     symmetry_operations = []
 *                 original_symmetry_operations = comm.bcast(original_symmetry_operations, root = 0)             # <<<<<<<<<<<<<<
 *                 symmetry_operations = comm.bcast(symmetry_operations, root = 0)
 * 
 */
      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(((PyObject *)__pyx_v_original_symmetry_operations));
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_original_symmetry_operations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_original_symmetry_operations));
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_t_9), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_original_symmetry_operations));
      __pyx_v_original_symmetry_operations = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;
 580:                 symmetry_operations = comm.bcast(symmetry_operations, root = 0)
      /* "water_algorithm_cython.pyx":580
 *                     symmetry_operations = []
 *                 original_symmetry_operations = comm.bcast(original_symmetry_operations, root = 0)
 *                 symmetry_operations = comm.bcast(symmetry_operations, root = 0)             # <<<<<<<<<<<<<<
 * 
 *                 #print_parallel("%i symmetry operations" % len(symmetry_operations), self.logfile)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operations));
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_symmetry_operations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operations));
      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
      if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_21 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_21))||((__pyx_t_21) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_21)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_symmetry_operations));
      __pyx_v_symmetry_operations = ((PyObject*)__pyx_t_21);
      __pyx_t_21 = 0;
 581: 
 582:                 #print_parallel("%i symmetry operations" % len(symmetry_operations), self.logfile)
 583:                 if len(symmetry_operations) > 0:
      /* "water_algorithm_cython.pyx":583
 * 
 *                 #print_parallel("%i symmetry operations" % len(symmetry_operations), self.logfile)
 *                 if len(symmetry_operations) > 0:             # <<<<<<<<<<<<<<
 *                     portion  = (<float>  len(symmetry_operations) / <float> len(self.symmetry_operations))
 *                     if portion < 0.25:
 */
      if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_28 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_28 > 0);
      if (__pyx_t_8) {
 584:                     portion  = (<float>  len(symmetry_operations) / <float> len(self.symmetry_operations))
        /* "water_algorithm_cython.pyx":584
 *                 #print_parallel("%i symmetry operations" % len(symmetry_operations), self.logfile)
 *                 if len(symmetry_operations) > 0:
 *                     portion  = (<float>  len(symmetry_operations) / <float> len(self.symmetry_operations))             # <<<<<<<<<<<<<<
 *                     if portion < 0.25:
 *                         portion = 0.25
 */
        if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_28 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_29 = ((float)__pyx_t_28);
        __pyx_t_21 = ((PyObject *)__pyx_v_self->symmetry_operations);
        __Pyx_INCREF(__pyx_t_21);
        if (unlikely(__pyx_t_21 == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_28 = PyList_GET_SIZE(__pyx_t_21); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __pyx_t_30 = ((float)__pyx_t_28);
        if (unlikely(__pyx_t_30 == 0)) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
          #endif
          PyErr_Format(PyExc_ZeroDivisionError, "float division");
          #ifdef WITH_THREAD
          PyGILState_Release(__pyx_gilstate_save);
          #endif
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_portion = (__pyx_t_29 / __pyx_t_30);
 585:                     if portion < 0.25:
        /* "water_algorithm_cython.pyx":585
 *                 if len(symmetry_operations) > 0:
 *                     portion  = (<float>  len(symmetry_operations) / <float> len(self.symmetry_operations))
 *                     if portion < 0.25:             # <<<<<<<<<<<<<<
 *                         portion = 0.25
 *                     else:
 */
        __pyx_t_8 = (__pyx_v_portion < 0.25);
        if (__pyx_t_8) {
 586:                         portion = 0.25
          /* "water_algorithm_cython.pyx":586
 *                     portion  = (<float>  len(symmetry_operations) / <float> len(self.symmetry_operations))
 *                     if portion < 0.25:
 *                         portion = 0.25             # <<<<<<<<<<<<<<
 *                     else:
 *                         portion = 0.25
 */
          __pyx_v_portion = 0.25;
          goto __pyx_L19;
        }
        /*else*/ {
 587:                     else:
 588:                         portion = 0.25
          /* "water_algorithm_cython.pyx":588
 *                         portion = 0.25
 *                     else:
 *                         portion = 0.25             # <<<<<<<<<<<<<<
 *                     portion = 1.0
 * 
 */
          __pyx_v_portion = 0.25;
        }
        __pyx_L19:;
 589:                     portion = 1.0
        /* "water_algorithm_cython.pyx":589
 *                     else:
 *                         portion = 0.25
 *                     portion = 1.0             # <<<<<<<<<<<<<<
 * 
 *                 result_group_count = <int> ( portion * <float> len(self.graph_invariants) - 1)
 */
        __pyx_v_portion = 1.0;
        goto __pyx_L18;
      }
      __pyx_L18:;
 590: 
 591:                 result_group_count = <int> ( portion * <float> len(self.graph_invariants) - 1)
      /* "water_algorithm_cython.pyx":591
 *                     portion = 1.0
 * 
 *                 result_group_count = <int> ( portion * <float> len(self.graph_invariants) - 1)             # <<<<<<<<<<<<<<
 *                 #print "Lenght before ssg %i, %i, %i" % (new_water_orientations.shape[0], len(self_symmetry_groups), rank)
 *                 if len(self_symmetry_groups) > 0:
 */
      __pyx_t_21 = ((PyObject *)__pyx_v_self->graph_invariants);
      __Pyx_INCREF(__pyx_t_21);
      if (unlikely(__pyx_t_21 == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_28 = PyList_GET_SIZE(__pyx_t_21); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_v_result_group_count = ((int)((__pyx_v_portion * ((float)__pyx_t_28)) - 1.0));
 592:                 #print "Lenght before ssg %i, %i, %i" % (new_water_orientations.shape[0], len(self_symmetry_groups), rank)
 593:                 if len(self_symmetry_groups) > 0:
      /* "water_algorithm_cython.pyx":593
 *                 result_group_count = <int> ( portion * <float> len(self.graph_invariants) - 1)
 *                 #print "Lenght before ssg %i, %i, %i" % (new_water_orientations.shape[0], len(self_symmetry_groups), rank)
 *                 if len(self_symmetry_groups) > 0:             # <<<<<<<<<<<<<<
 *                     self_symmetry_groups, new_water_orientations = self.handle_self_symmetry_groups(new_water_orientations, i,  self_symmetry_groups, original_symmetry_operations, result_group_count, save_self_symmetry_groups, all_symmetries_found, possible_combinations)
 *                     print_("|---------------------------------------|", self.logfile)
 */
      if (unlikely(((PyObject *)__pyx_v_self_symmetry_groups) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_28 = PyList_GET_SIZE(((PyObject *)__pyx_v_self_symmetry_groups)); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_28 > 0);
      if (__pyx_t_8) {
 594:                     self_symmetry_groups, new_water_orientations = self.handle_self_symmetry_groups(new_water_orientations, i,  self_symmetry_groups, original_symmetry_operations, result_group_count, save_self_symmetry_groups, all_symmetries_found, possible_combinations)
        /* "water_algorithm_cython.pyx":594
 *                 #print "Lenght before ssg %i, %i, %i" % (new_water_orientations.shape[0], len(self_symmetry_groups), rank)
 *                 if len(self_symmetry_groups) > 0:
 *                     self_symmetry_groups, new_water_orientations = self.handle_self_symmetry_groups(new_water_orientations, i,  self_symmetry_groups, original_symmetry_operations, result_group_count, save_self_symmetry_groups, all_symmetries_found, possible_combinations)             # <<<<<<<<<<<<<<
 *                     print_("|---------------------------------------|", self.logfile)
 *                 #print_symmetry_operations(symmetry_operations)
 */
        __pyx_t_31 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_new_water_orientations));
        if (unlikely(!__pyx_t_31.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_21 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->handle_self_symmetry_groups(__pyx_v_self, __pyx_t_31, __pyx_v_i, __pyx_v_self_symmetry_groups, __pyx_v_original_symmetry_operations, __pyx_v_result_group_count, __pyx_v_save_self_symmetry_groups, __pyx_v_all_symmetries_found, __pyx_v_possible_combinations)); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
        if (likely(PyTuple_CheckExact(__pyx_t_21))) {
          PyObject* sequence = __pyx_t_21;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_6);
          #else
          __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          #endif
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        } else if (1) {
          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        } else
        {
          Py_ssize_t index = -1;
          __pyx_t_2 = PyObject_GetIter(__pyx_t_21); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          __pyx_t_32 = Py_TYPE(__pyx_t_2)->tp_iternext;
          index = 0; __pyx_t_9 = __pyx_t_32(__pyx_t_2); if (unlikely(!__pyx_t_9)) goto __pyx_L21_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_9);
          index = 1; __pyx_t_6 = __pyx_t_32(__pyx_t_2); if (unlikely(!__pyx_t_6)) goto __pyx_L21_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_6);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_32(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_32 = NULL;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L22_unpacking_done;
          __pyx_L21_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_32 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L22_unpacking_done:;
        }
        if (!(likely(PyList_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_9)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_self_symmetry_groups));
        __pyx_v_self_symmetry_groups = ((PyObject*)__pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_20 = ((PyArrayObject *)__pyx_t_6);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_20 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_6);
        __pyx_t_6 = 0;
 595:                     print_("|---------------------------------------|", self.logfile)
        /* "water_algorithm_cython.pyx":595
 *                 if len(self_symmetry_groups) > 0:
 *                     self_symmetry_groups, new_water_orientations = self.handle_self_symmetry_groups(new_water_orientations, i,  self_symmetry_groups, original_symmetry_operations, result_group_count, save_self_symmetry_groups, all_symmetries_found, possible_combinations)
 *                     print_("|---------------------------------------|", self.logfile)             # <<<<<<<<<<<<<<
 *                 #print_symmetry_operations(symmetry_operations)
 *                 #print_parallel(new_water_orientations, self.logfile)
 */
        __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_69));
        PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_69));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_69));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_9 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L20;
      }
      __pyx_L20:;
 596:                 #print_symmetry_operations(symmetry_operations)
 597:                 #print_parallel(new_water_orientations, self.logfile)
 598:                 if len(symmetry_operations) > 0:
      /* "water_algorithm_cython.pyx":598
 *                 #print_symmetry_operations(symmetry_operations)
 *                 #print_parallel(new_water_orientations, self.logfile)
 *                 if len(symmetry_operations) > 0:             # <<<<<<<<<<<<<<
 *                     new_water_orientations = self.remove_symmetric_results(new_water_orientations, i, symmetry_operations, result_group_count, self_symmetry_groups, save_self_symmetry_groups, [], None, 1, not all_symmetries_found)#  self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i, original_symmetry_operations, self_symmetry_groups, save_self_symmetry_groups) #          #
 *                     if save_self_symmetry_groups:
 */
      if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_28 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_28 > 0);
      if (__pyx_t_8) {
 599:                     new_water_orientations = self.remove_symmetric_results(new_water_orientations, i, symmetry_operations, result_group_count, self_symmetry_groups, save_self_symmetry_groups, [], None, 1, not all_symmetries_found)#  self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i, original_symmetry_operations, self_symmetry_groups, save_self_symmetry_groups) #          #
        /* "water_algorithm_cython.pyx":599
 *                 #print_parallel(new_water_orientations, self.logfile)
 *                 if len(symmetry_operations) > 0:
 *                     new_water_orientations = self.remove_symmetric_results(new_water_orientations, i, symmetry_operations, result_group_count, self_symmetry_groups, save_self_symmetry_groups, [], None, 1, not all_symmetries_found)#  self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i, original_symmetry_operations, self_symmetry_groups, save_self_symmetry_groups) #          #             # <<<<<<<<<<<<<<
 *                     if save_self_symmetry_groups:
 *                         mark_earlier_found(symmetry_operations, self.symmetry_operations)
 */
        __pyx_t_33 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_new_water_orientations));
        if (unlikely(!__pyx_t_33.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->remove_symmetric_results(__pyx_v_self, __pyx_t_33, __pyx_v_i, __pyx_v_symmetry_operations, __pyx_v_result_group_count, __pyx_v_self_symmetry_groups, __pyx_v_save_self_symmetry_groups, ((PyObject*)__pyx_t_9), ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)Py_None), 1, (!__pyx_v_all_symmetries_found))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __PYX_XDEC_MEMVIEW(&__pyx_t_33, 1);
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_6), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            }
          }
          __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
        __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_6);
        __pyx_t_6 = 0;
 600:                     if save_self_symmetry_groups:
        /* "water_algorithm_cython.pyx":600
 *                 if len(symmetry_operations) > 0:
 *                     new_water_orientations = self.remove_symmetric_results(new_water_orientations, i, symmetry_operations, result_group_count, self_symmetry_groups, save_self_symmetry_groups, [], None, 1, not all_symmetries_found)#  self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i, original_symmetry_operations, self_symmetry_groups, save_self_symmetry_groups) #          #
 *                     if save_self_symmetry_groups:             # <<<<<<<<<<<<<<
 *                         mark_earlier_found(symmetry_operations, self.symmetry_operations)
 *                         all_symmetries_found = all_found(self.symmetry_operations)
 */
        if (__pyx_v_save_self_symmetry_groups) {
 601:                         mark_earlier_found(symmetry_operations, self.symmetry_operations)
          /* "water_algorithm_cython.pyx":601
 *                     new_water_orientations = self.remove_symmetric_results(new_water_orientations, i, symmetry_operations, result_group_count, self_symmetry_groups, save_self_symmetry_groups, [], None, 1, not all_symmetries_found)#  self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i, original_symmetry_operations, self_symmetry_groups, save_self_symmetry_groups) #          #
 *                     if save_self_symmetry_groups:
 *                         mark_earlier_found(symmetry_operations, self.symmetry_operations)             # <<<<<<<<<<<<<<
 *                         all_symmetries_found = all_found(self.symmetry_operations)
 *                         # If all symmetry operations have been found, do the final scatter
 */
          __pyx_t_6 = ((PyObject *)__pyx_v_self->symmetry_operations);
          __Pyx_INCREF(__pyx_t_6);
          __pyx_f_10symmetries_25symmetry_operation_cython_mark_earlier_found(__pyx_v_symmetry_operations, ((PyObject*)__pyx_t_6));
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 602:                         all_symmetries_found = all_found(self.symmetry_operations)
          /* "water_algorithm_cython.pyx":602
 *                     if save_self_symmetry_groups:
 *                         mark_earlier_found(symmetry_operations, self.symmetry_operations)
 *                         all_symmetries_found = all_found(self.symmetry_operations)             # <<<<<<<<<<<<<<
 *                         # If all symmetry operations have been found, do the final scatter
 *                         if all_symmetries_found:
 */
          __pyx_t_6 = ((PyObject *)__pyx_v_self->symmetry_operations);
          __Pyx_INCREF(__pyx_t_6);
          __pyx_v_all_symmetries_found = __pyx_f_10symmetries_25symmetry_operation_cython_all_found(((PyObject*)__pyx_t_6));
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 603:                         # If all symmetry operations have been found, do the final scatter
 604:                         if all_symmetries_found:
          /* "water_algorithm_cython.pyx":604
 *                         all_symmetries_found = all_found(self.symmetry_operations)
 *                         # If all symmetry operations have been found, do the final scatter
 *                         if all_symmetries_found:             # <<<<<<<<<<<<<<
 *                             new_water_orientations = comm.scatter(split_list(new_water_orientations,  size),  root = 0)
 *                             #self_symmetry_groups = comm.scatter(split_list(self_symmetry_groups, size), root = 0)
 */
          if (__pyx_v_all_symmetries_found) {
 605:                             new_water_orientations = comm.scatter(split_list(new_water_orientations,  size),  root = 0)
            /* "water_algorithm_cython.pyx":605
 *                         # If all symmetry operations have been found, do the final scatter
 *                         if all_symmetries_found:
 *                             new_water_orientations = comm.scatter(split_list(new_water_orientations,  size),  root = 0)             # <<<<<<<<<<<<<<
 *                             #self_symmetry_groups = comm.scatter(split_list(self_symmetry_groups, size), root = 0)
 *                 else:
 */
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_21 = PyInt_FromLong(size); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_21);
            __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
            PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_new_water_orientations));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
            PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_21);
            __Pyx_GIVEREF(__pyx_t_21);
            __pyx_t_21 = 0;
            __pyx_t_21 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_21);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
            __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_21);
            __Pyx_GIVEREF(__pyx_t_21);
            __pyx_t_21 = 0;
            __pyx_t_21 = PyDict_New(); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_21));
            if (PyDict_SetItem(__pyx_t_21, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_21)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
            if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_20 = ((PyArrayObject *)__pyx_t_9);
            {
              __Pyx_BufFmt_StackElem __pyx_stack[1];
              __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
              __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
              if (unlikely(__pyx_t_5 < 0)) {
                PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
                if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
                  Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
                  __Pyx_RaiseBufferFallbackError();
                } else {
                  PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
                }
              }
              __pyx_pybuffernd_new_water_orientations.diminfo[0].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_water_orientations.diminfo[0].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_new_water_orientations.diminfo[1].strides = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_new_water_orientations.diminfo[1].shape = __pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer.shape[1];
              if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_20 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_v_new_water_orientations));
            __pyx_v_new_water_orientations = ((PyArrayObject *)__pyx_t_9);
            __pyx_t_9 = 0;
            goto __pyx_L25;
          }
          __pyx_L25:;
          goto __pyx_L24;
        }
        __pyx_L24:;
        goto __pyx_L23;
      }
      /*else*/ {
 606:                             #self_symmetry_groups = comm.scatter(split_list(self_symmetry_groups, size), root = 0)
 607:                 else:
 608:                     print_parallel("Skipping symmetry checking.", self.logfile)
        /* "water_algorithm_cython.pyx":608
 *                             #self_symmetry_groups = comm.scatter(split_list(self_symmetry_groups, size), root = 0)
 *                 else:
 *                     print_parallel("Skipping symmetry checking.", self.logfile)             # <<<<<<<<<<<<<<
 *                     print_("Skipping symmetry checking.", self.logfile)
 *                     print "Finally %i geometries in main thread." % len(new_water_orientations), None
 */
        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_70));
        PyTuple_SET_ITEM(__pyx_t_21, 0, ((PyObject *)__pyx_kp_s_70));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_70));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_2 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_21), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 609:                     print_("Skipping symmetry checking.", self.logfile)
        /* "water_algorithm_cython.pyx":609
 *                 else:
 *                     print_parallel("Skipping symmetry checking.", self.logfile)
 *                     print_("Skipping symmetry checking.", self.logfile)             # <<<<<<<<<<<<<<
 *                     print "Finally %i geometries in main thread." % len(new_water_orientations), None
 * 
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_70));
        PyTuple_SET_ITEM(__pyx_t_21, 0, ((PyObject *)__pyx_kp_s_70));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_70));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_9 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_21), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 610:                     print "Finally %i geometries in main thread." % len(new_water_orientations), None
        /* "water_algorithm_cython.pyx":610
 *                     print_parallel("Skipping symmetry checking.", self.logfile)
 *                     print_("Skipping symmetry checking.", self.logfile)
 *                     print "Finally %i geometries in main thread." % len(new_water_orientations), None             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_28 = PyObject_Length(((PyObject *)__pyx_v_new_water_orientations)); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_28); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_21 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_71), __pyx_t_9); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_21));
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_21));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_21));
        __Pyx_INCREF(Py_None);
        PyTuple_SET_ITEM(__pyx_t_9, 1, Py_None);
        __Pyx_GIVEREF(Py_None);
        __pyx_t_21 = 0;
        if (__Pyx_Print(0, ((PyObject *)__pyx_t_9), 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      }
      __pyx_L23:;
      goto __pyx_L15;
    }
    __pyx_L15:;
 611: 
 612: 
 613: 
 614:             #self.symmetry_total_time = (time()-s)
 615:             self.save_results(i, new_water_orientations, order, all_symmetries_found = all_symmetries_found)
    /* "water_algorithm_cython.pyx":615
 * 
 *             #self.symmetry_total_time = (time()-s)
 *             self.save_results(i, new_water_orientations, order, all_symmetries_found = all_symmetries_found)             # <<<<<<<<<<<<<<
 * 
 *         #Call the next round (i=i + 1) or return the results
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__save_results); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_21 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_21);
    __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_new_water_orientations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_new_water_orientations));
    __Pyx_INCREF(((PyObject *)__pyx_v_order));
    PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_order));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_order));
    __pyx_t_21 = 0;
    __pyx_t_21 = PyDict_New(); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_21));
    __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_all_symmetries_found); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_21, ((PyObject *)__pyx_n_s_54), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_21)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_L6:;
 616: 
 617:         #Call the next round (i=i + 1) or return the results
 618:         number = 0
  /* "water_algorithm_cython.pyx":618
 * 
 *         #Call the next round (i=i + 1) or return the results
 *         number = 0             # <<<<<<<<<<<<<<
 *         for l,  n in enumerate(order):
 *             if n == i:
 */
  __pyx_v_number = 0;
 619:         for l,  n in enumerate(order):
  /* "water_algorithm_cython.pyx":619
 *         #Call the next round (i=i + 1) or return the results
 *         number = 0
 *         for l,  n in enumerate(order):             # <<<<<<<<<<<<<<
 *             if n == i:
 *                 number = l
 */
  __pyx_t_5 = 0;
  if (PyList_CheckExact(((PyObject *)__pyx_v_order)) || PyTuple_CheckExact(((PyObject *)__pyx_v_order))) {
    __pyx_t_6 = ((PyObject *)__pyx_v_order); __Pyx_INCREF(__pyx_t_6); __pyx_t_28 = 0;
    __pyx_t_34 = NULL;
  } else {
    __pyx_t_28 = -1; __pyx_t_6 = PyObject_GetIter(((PyObject *)__pyx_v_order)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_34 = Py_TYPE(__pyx_t_6)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_34 && PyList_CheckExact(__pyx_t_6)) {
      if (__pyx_t_28 >= PyList_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_21 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_28); __Pyx_INCREF(__pyx_t_21); __pyx_t_28++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_21 = PySequence_ITEM(__pyx_t_6, __pyx_t_28); __pyx_t_28++; if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_34 && PyTuple_CheckExact(__pyx_t_6)) {
      if (__pyx_t_28 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_21 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_28); __Pyx_INCREF(__pyx_t_21); __pyx_t_28++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_21 = PySequence_ITEM(__pyx_t_6, __pyx_t_28); __pyx_t_28++; if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_21 = __pyx_t_34(__pyx_t_6);
      if (unlikely(!__pyx_t_21)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_21);
    }
    __Pyx_XDECREF(__pyx_v_n);
    __pyx_v_n = __pyx_t_21;
    __pyx_t_21 = 0;
    __pyx_v_l = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);
 620:             if n == i:
    /* "water_algorithm_cython.pyx":620
 *         number = 0
 *         for l,  n in enumerate(order):
 *             if n == i:             # <<<<<<<<<<<<<<
 *                 number = l
 *                 break
 */
    __pyx_t_21 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_n, __pyx_t_21, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_8) {
 621:                 number = l
      /* "water_algorithm_cython.pyx":621
 *         for l,  n in enumerate(order):
 *             if n == i:
 *                 number = l             # <<<<<<<<<<<<<<
 *                 break
 * 
 */
      __pyx_v_number = __pyx_v_l;
 622:                 break
      /* "water_algorithm_cython.pyx":622
 *             if n == i:
 *                 number = l
 *                 break             # <<<<<<<<<<<<<<
 * 
 *         #print "number is %i, rank: %i" % (number, rank)
 */
      goto __pyx_L27_break;
      goto __pyx_L28;
    }
    __pyx_L28:;
  }
  __pyx_L27_break:;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 623: 
 624:         #print "number is %i, rank: %i" % (number, rank)
 625:         if(number+1 != len(nearest_neighbors_nos[0])):
  /* "water_algorithm_cython.pyx":625
 * 
 *         #print "number is %i, rank: %i" % (number, rank)
 *         if(number+1 != len(nearest_neighbors_nos[0])):             # <<<<<<<<<<<<<<
 *             #print "Here again?"
 *             return self.perform_2(new_water_orientations, order[number+1], order, do_symmetry_check, -1, 0, self_symmetry_groups)
 */
  __pyx_t_5 = -1;
  __pyx_t_35.data = __pyx_v_nearest_neighbors_nos.data;
  __pyx_t_35.memview = __pyx_v_nearest_neighbors_nos.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_35, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_35.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_35.shape[0] = __pyx_v_nearest_neighbors_nos.shape[1];
__pyx_t_35.strides[0] = __pyx_v_nearest_neighbors_nos.strides[1];
    __pyx_t_35.suboffsets[0] = -1;

__pyx_t_35.shape[1] = __pyx_v_nearest_neighbors_nos.shape[2];
__pyx_t_35.strides[1] = __pyx_v_nearest_neighbors_nos.strides[2];
    __pyx_t_35.suboffsets[1] = -1;

__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_t_35, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE_t, 0);; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_35, 1);
  __pyx_t_28 = PyObject_Length(__pyx_t_6); if (unlikely(__pyx_t_28 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = ((__pyx_v_number + 1) != __pyx_t_28);
  if (__pyx_t_8) {
 626:             #print "Here again?"
 627:             return self.perform_2(new_water_orientations, order[number+1], order, do_symmetry_check, -1, 0, self_symmetry_groups)
    /* "water_algorithm_cython.pyx":627
 *         if(number+1 != len(nearest_neighbors_nos[0])):
 *             #print "Here again?"
 *             return self.perform_2(new_water_orientations, order[number+1], order, do_symmetry_check, -1, 0, self_symmetry_groups)             # <<<<<<<<<<<<<<
 *         else:
 *             self.print_time_stats()
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __pyx_t_27 = (__pyx_v_number + 1);
    __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->perform_2(__pyx_v_self, ((PyArrayObject *)__pyx_v_new_water_orientations), (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_order.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_order.diminfo[0].strides)), ((PyArrayObject *)__pyx_v_order), ((PyArrayObject *)__pyx_v_do_symmetry_check), -1, 0, __pyx_v_self_symmetry_groups)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_r = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L0;
    goto __pyx_L29;
  }
  /*else*/ {
 628:         else:
 629:             self.print_time_stats()
    /* "water_algorithm_cython.pyx":629
 *             return self.perform_2(new_water_orientations, order[number+1], order, do_symmetry_check, -1, 0, self_symmetry_groups)
 *         else:
 *             self.print_time_stats()             # <<<<<<<<<<<<<<
 *             return new_water_orientations
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__print_time_stats); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 630:             return new_water_orientations
    /* "water_algorithm_cython.pyx":630
 *         else:
 *             self.print_time_stats()
 *             return new_water_orientations             # <<<<<<<<<<<<<<
 * 
 *     def get_coordination_number(self, i):
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_new_water_orientations));
    __pyx_r = ((PyArrayObject *)__pyx_v_new_water_orientations);
    goto __pyx_L0;
  }
  __pyx_L29:;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_XDECREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_21);
  __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_33, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_35, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.perform_2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_do_symmetry_check.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_water_orientations.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_order.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_nearest_neighbors_nos, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_nn, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_new_water_orientations);
  __Pyx_XDECREF(__pyx_v_symmetry_operations);
  __Pyx_XDECREF(__pyx_v_original_symmetry_operations);
  __PYX_XDEC_MEMVIEW(&__pyx_v_possible_combinations, 1);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientations);
  __Pyx_XDECREF((PyObject *)__pyx_v_order);
  __Pyx_XDECREF((PyObject *)__pyx_v_do_symmetry_check);
  __Pyx_XDECREF(__pyx_v_self_symmetry_groups);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_33get_coordination_number(PyObject *__pyx_v_self, PyObject *__pyx_v_i); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_33get_coordination_number(PyObject *__pyx_v_self, PyObject *__pyx_v_i) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_coordination_number (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_32get_coordination_number(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_i));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 631: 
 632:     def get_coordination_number(self, i):
/* "water_algorithm_cython.pyx":632
 *             return new_water_orientations
 * 
 *     def get_coordination_number(self, i):             # <<<<<<<<<<<<<<
 *         result = 4
 *         for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_32get_coordination_number(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_i) {
  long __pyx_v_result;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_nn = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_coordination_number", 0);
 633:         result = 4
  /* "water_algorithm_cython.pyx":633
 * 
 *     def get_coordination_number(self, i):
 *         result = 4             # <<<<<<<<<<<<<<
 *         for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *             if nn == i and not self.nearest_neighbors_nos[1][i][j]:
 */
  __pyx_v_result = 4;
 634:         for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
  /* "water_algorithm_cython.pyx":634
 *     def get_coordination_number(self, i):
 *         result = 4
 *         for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):             # <<<<<<<<<<<<<<
 *             if nn == i and not self.nearest_neighbors_nos[1][i][j]:
 *                 result -= 1
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_t_3, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_nn);
    __pyx_v_nn = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_j);
    __pyx_v_j = __pyx_t_1;
    __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
 635:             if nn == i and not self.nearest_neighbors_nos[1][i][j]:
    /* "water_algorithm_cython.pyx":635
 *         result = 4
 *         for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *             if nn == i and not self.nearest_neighbors_nos[1][i][j]:             # <<<<<<<<<<<<<<
 *                 result -= 1
 *         return result
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_nn, __pyx_v_i, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_6) {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_2, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(__pyx_t_7, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_GetItem(__pyx_t_2, __pyx_v_j); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9 = (!__pyx_t_8);
      __pyx_t_8 = __pyx_t_9;
    } else {
      __pyx_t_8 = __pyx_t_6;
    }
    if (__pyx_t_8) {
 636:                 result -= 1
      /* "water_algorithm_cython.pyx":636
 *         for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *             if nn == i and not self.nearest_neighbors_nos[1][i][j]:
 *                 result -= 1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
      __pyx_v_result = (__pyx_v_result - 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 637:         return result
  /* "water_algorithm_cython.pyx":637
 *             if nn == i and not self.nearest_neighbors_nos[1][i][j]:
 *                 result -= 1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def get_sample_charge(self, water_orientations):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_coordination_number", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_nn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_35get_sample_charge(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientations); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_35get_sample_charge(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientations) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sample_charge (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_34get_sample_charge(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_water_orientations));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 638: 
 639:     def get_sample_charge(self, water_orientations):
/* "water_algorithm_cython.pyx":639
 *         return result
 * 
 *     def get_sample_charge(self, water_orientations):             # <<<<<<<<<<<<<<
 *         result = 0
 *         for orientation in water_orientations:
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_34get_sample_charge(CYTHON_UNUSED struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientations) {
  long __pyx_v_result;
  PyObject *__pyx_v_orientation = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_sample_charge", 0);
 640:         result = 0
  /* "water_algorithm_cython.pyx":640
 * 
 *     def get_sample_charge(self, water_orientations):
 *         result = 0             # <<<<<<<<<<<<<<
 *         for orientation in water_orientations:
 *             if orientation > 9:
 */
  __pyx_v_result = 0;
 641:         for orientation in water_orientations:
  /* "water_algorithm_cython.pyx":641
 *     def get_sample_charge(self, water_orientations):
 *         result = 0
 *         for orientation in water_orientations:             # <<<<<<<<<<<<<<
 *             if orientation > 9:
 *                 result += 1
 */
  if (PyList_CheckExact(__pyx_v_water_orientations) || PyTuple_CheckExact(__pyx_v_water_orientations)) {
    __pyx_t_1 = __pyx_v_water_orientations; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_water_orientations); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_orientation);
    __pyx_v_orientation = __pyx_t_4;
    __pyx_t_4 = 0;
 642:             if orientation > 9:
    /* "water_algorithm_cython.pyx":642
 *         result = 0
 *         for orientation in water_orientations:
 *             if orientation > 9:             # <<<<<<<<<<<<<<
 *                 result += 1
 *             elif orientation > 5:
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_orientation, __pyx_int_9, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_5) {
 643:                 result += 1
      /* "water_algorithm_cython.pyx":643
 *         for orientation in water_orientations:
 *             if orientation > 9:
 *                 result += 1             # <<<<<<<<<<<<<<
 *             elif orientation > 5:
 *                 result -= 1
 */
      __pyx_v_result = (__pyx_v_result + 1);
      goto __pyx_L5;
    }
 644:             elif orientation > 5:
    /* "water_algorithm_cython.pyx":644
 *             if orientation > 9:
 *                 result += 1
 *             elif orientation > 5:             # <<<<<<<<<<<<<<
 *                 result -= 1
 *         return result
 */
    __pyx_t_4 = PyObject_RichCompare(__pyx_v_orientation, __pyx_int_5, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_5) {
 645:                 result -= 1
      /* "water_algorithm_cython.pyx":645
 *                 result += 1
 *             elif orientation > 5:
 *                 result -= 1             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
      __pyx_v_result = (__pyx_v_result - 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 646:         return result
  /* "water_algorithm_cython.pyx":646
 *             elif orientation > 5:
 *                 result -= 1
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def handle_charges(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_result); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_sample_charge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_orientation);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_37handle_charges(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_37handle_charges(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_charges (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_36handle_charges(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 647: 
 648:     def handle_charges(self):
/* "water_algorithm_cython.pyx":648
 *         return result
 * 
 *     def handle_charges(self):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t H3O_count = self.dissosiation_count + (abs(self.charge) + self.charge) / 2
 *         cdef DTYPE2_t OH_count = self.dissosiation_count + (abs(self.charge) - self.charge) / 2
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_36handle_charges(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_H3O_count;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_OH_count;
  PyArrayObject *__pyx_v_water_orientations = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_charges", 0);
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
 649:         cdef DTYPE2_t H3O_count = self.dissosiation_count + (abs(self.charge) + self.charge) / 2
  /* "water_algorithm_cython.pyx":649
 * 
 *     def handle_charges(self):
 *         cdef DTYPE2_t H3O_count = self.dissosiation_count + (abs(self.charge) + self.charge) / 2             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t OH_count = self.dissosiation_count + (abs(self.charge) - self.charge) / 2
 *         if OH_count == 0 and H3O_count == 0:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->dissosiation_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->charge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Absolute(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->charge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_4); if (unlikely((__pyx_t_5 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_H3O_count = __pyx_t_5;
 650:         cdef DTYPE2_t OH_count = self.dissosiation_count + (abs(self.charge) - self.charge) / 2
  /* "water_algorithm_cython.pyx":650
 *     def handle_charges(self):
 *         cdef DTYPE2_t H3O_count = self.dissosiation_count + (abs(self.charge) + self.charge) / 2
 *         cdef DTYPE2_t OH_count = self.dissosiation_count + (abs(self.charge) - self.charge) / 2             # <<<<<<<<<<<<<<
 *         if OH_count == 0 and H3O_count == 0:
 *             return np.zeros((0, self.N),  dtype=DTYPE2)
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_self->dissosiation_count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->charge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Absolute(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->charge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_3); if (unlikely((__pyx_t_5 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_OH_count = __pyx_t_5;
 651:         if OH_count == 0 and H3O_count == 0:
  /* "water_algorithm_cython.pyx":651
 *         cdef DTYPE2_t H3O_count = self.dissosiation_count + (abs(self.charge) + self.charge) / 2
 *         cdef DTYPE2_t OH_count = self.dissosiation_count + (abs(self.charge) - self.charge) / 2
 *         if OH_count == 0 and H3O_count == 0:             # <<<<<<<<<<<<<<
 *             return np.zeros((0, self.N),  dtype=DTYPE2)
 * 
 */
  __pyx_t_6 = (__pyx_v_OH_count == 0);
  if (__pyx_t_6) {
    __pyx_t_7 = (__pyx_v_H3O_count == 0);
    __pyx_t_8 = __pyx_t_7;
  } else {
    __pyx_t_8 = __pyx_t_6;
  }
  if (__pyx_t_8) {
 652:             return np.zeros((0, self.N),  dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":652
 *         cdef DTYPE2_t OH_count = self.dissosiation_count + (abs(self.charge) - self.charge) / 2
 *         if OH_count == 0 and H3O_count == 0:
 *             return np.zeros((0, self.N),  dtype=DTYPE2)             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[DTYPE2_t, ndim=2] water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 653: 
 654:         cdef np.ndarray[DTYPE2_t, ndim=2] water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":654
 *             return np.zeros((0, self.N),  dtype=DTYPE2)
 * 
 *         cdef np.ndarray[DTYPE2_t, ndim=2] water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         if H3O_count != 0:
 *             print_parallel("Handling H3O+ molecules", self.logfile)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_water_orientations = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 655:         if H3O_count != 0:
  /* "water_algorithm_cython.pyx":655
 * 
 *         cdef np.ndarray[DTYPE2_t, ndim=2] water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 *         if H3O_count != 0:             # <<<<<<<<<<<<<<
 *             print_parallel("Handling H3O+ molecules", self.logfile)
 *             print_parallel("---------------------------------------------", self.logfile)
 */
  __pyx_t_8 = (__pyx_v_H3O_count != 0);
  if (__pyx_t_8) {
 656:             print_parallel("Handling H3O+ molecules", self.logfile)
    /* "water_algorithm_cython.pyx":656
 *         cdef np.ndarray[DTYPE2_t, ndim=2] water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 *         if H3O_count != 0:
 *             print_parallel("Handling H3O+ molecules", self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("---------------------------------------------", self.logfile)
 *             water_orientations = self.handle_charge(water_orientations, H3O_count, np.array([10, 11, 12, 13], dtype=DTYPE2))
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_72));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_72));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_72));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 657:             print_parallel("---------------------------------------------", self.logfile)
    /* "water_algorithm_cython.pyx":657
 *         if H3O_count != 0:
 *             print_parallel("Handling H3O+ molecules", self.logfile)
 *             print_parallel("---------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *             water_orientations = self.handle_charge(water_orientations, H3O_count, np.array([10, 11, 12, 13], dtype=DTYPE2))
 *         if OH_count != 0:
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_73));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_73));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_73));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 658:             water_orientations = self.handle_charge(water_orientations, H3O_count, np.array([10, 11, 12, 13], dtype=DTYPE2))
    /* "water_algorithm_cython.pyx":658
 *             print_parallel("Handling H3O+ molecules", self.logfile)
 *             print_parallel("---------------------------------------------", self.logfile)
 *             water_orientations = self.handle_charge(water_orientations, H3O_count, np.array([10, 11, 12, 13], dtype=DTYPE2))             # <<<<<<<<<<<<<<
 *         if OH_count != 0:
 *             print_parallel("Handling OH- molecules", self.logfile)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__handle_charge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_H3O_count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_10);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_10);
    __Pyx_GIVEREF(__pyx_int_10);
    __Pyx_INCREF(__pyx_int_11);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_11);
    __Pyx_GIVEREF(__pyx_int_11);
    __Pyx_INCREF(__pyx_int_12);
    PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_12);
    __Pyx_GIVEREF(__pyx_int_12);
    __Pyx_INCREF(__pyx_int_13);
    PyList_SET_ITEM(__pyx_t_1, 3, __pyx_int_13);
    __Pyx_GIVEREF(__pyx_int_13);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_10), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_water_orientations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_11);
    __pyx_t_3 = 0;
    __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
      __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_12 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
        }
      }
      __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
    __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;
 659:         if OH_count != 0:
  /* "water_algorithm_cython.pyx":659
 *             print_parallel("---------------------------------------------", self.logfile)
 *             water_orientations = self.handle_charge(water_orientations, H3O_count, np.array([10, 11, 12, 13], dtype=DTYPE2))
 *         if OH_count != 0:             # <<<<<<<<<<<<<<
 *             print_parallel("Handling OH- molecules", self.logfile)
 *             print_parallel("---------------------------------------------", self.logfile)
 */
  __pyx_t_8 = (__pyx_v_OH_count != 0);
  if (__pyx_t_8) {
 660:             print_parallel("Handling OH- molecules", self.logfile)
    /* "water_algorithm_cython.pyx":660
 *             water_orientations = self.handle_charge(water_orientations, H3O_count, np.array([10, 11, 12, 13], dtype=DTYPE2))
 *         if OH_count != 0:
 *             print_parallel("Handling OH- molecules", self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("---------------------------------------------", self.logfile)
 *             water_orientations = self.handle_charge(water_orientations, OH_count, np.array([6, 7, 8, 9], dtype=DTYPE2))
 */
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_74));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_74));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_74));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 661:             print_parallel("---------------------------------------------", self.logfile)
    /* "water_algorithm_cython.pyx":661
 *         if OH_count != 0:
 *             print_parallel("Handling OH- molecules", self.logfile)
 *             print_parallel("---------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *             water_orientations = self.handle_charge(water_orientations, OH_count, np.array([6, 7, 8, 9], dtype=DTYPE2))
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_73));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_73));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_73));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_11 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
 662:             water_orientations = self.handle_charge(water_orientations, OH_count, np.array([6, 7, 8, 9], dtype=DTYPE2))
    /* "water_algorithm_cython.pyx":662
 *             print_parallel("Handling OH- molecules", self.logfile)
 *             print_parallel("---------------------------------------------", self.logfile)
 *             water_orientations = self.handle_charge(water_orientations, OH_count, np.array([6, 7, 8, 9], dtype=DTYPE2))             # <<<<<<<<<<<<<<
 * 
 *         return water_orientations
 */
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__handle_charge); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_OH_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_int_6);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_6);
    __Pyx_GIVEREF(__pyx_int_6);
    __Pyx_INCREF(__pyx_int_7);
    PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_7);
    __Pyx_GIVEREF(__pyx_int_7);
    __Pyx_INCREF(__pyx_int_8);
    PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_8);
    __Pyx_GIVEREF(__pyx_int_8);
    __Pyx_INCREF(__pyx_int_9);
    PyList_SET_ITEM(__pyx_t_2, 3, __pyx_int_9);
    __Pyx_GIVEREF(__pyx_int_9);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_10), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_water_orientations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
      __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_12 < 0)) {
        PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
        }
      }
      __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
    __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;
 663: 
 664:         return water_orientations
  /* "water_algorithm_cython.pyx":664
 *             water_orientations = self.handle_charge(water_orientations, OH_count, np.array([6, 7, 8, 9], dtype=DTYPE2))
 * 
 *         return water_orientations             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
  __pyx_r = ((PyObject *)__pyx_v_water_orientations);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_charges", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientations);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_39handle_charge(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_38handle_charge[] = "\n            charge_left means the number of charges particles left to be set\n            orientations means the orientations possible for this particle (OH or H30)\n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_39handle_charge(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_water_orientations = 0;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_charge_left;
  PyArrayObject *__pyx_v_orientations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_charge (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_orientations,&__pyx_n_s__charge_left,&__pyx_n_s__orientations,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientations)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__charge_left)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("handle_charge", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__orientations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("handle_charge", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "handle_charge") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_water_orientations = ((PyArrayObject *)values[0]);
    __pyx_v_charge_left = __Pyx_PyInt_from_py_npy_int8(values[1]); if (unlikely((__pyx_v_charge_left == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_orientations = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_charge", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_charge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_water_orientations), __pyx_ptype_5numpy_ndarray, 1, "water_orientations", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_orientations), __pyx_ptype_5numpy_ndarray, 1, "orientations", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_38handle_charge(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_water_orientations, __pyx_v_charge_left, __pyx_v_orientations);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 665: 
 666: 
 667: 
 668: 
 669:     def handle_charge(self, np.ndarray[DTYPE2_t, ndim=2]  water_orientations, DTYPE2_t charge_left, np.ndarray[DTYPE2_t, ndim=1] orientations):
/* "water_algorithm_cython.pyx":669
 * 
 * 
 *     def handle_charge(self, np.ndarray[DTYPE2_t, ndim=2]  water_orientations, DTYPE2_t charge_left, np.ndarray[DTYPE2_t, ndim=1] orientations):             # <<<<<<<<<<<<<<
 *         """
 *             charge_left means the number of charges particles left to be set
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_38handle_charge(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyArrayObject *__pyx_v_water_orientations, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_charge_left, PyArrayObject *__pyx_v_orientations) {
  long __pyx_v_iteration;
  PyObject *__pyx_v_discarded = NULL;
  PyObject *__pyx_v_new_water_orientations = NULL;
  PyObject *__pyx_v_water_orient = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_l = NULL;
  PyObject *__pyx_v_d = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_orientations;
  __Pyx_Buffer __pyx_pybuffer_orientations;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_charge", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_water_orientations);
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
  __pyx_pybuffer_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_orientations.refcount = 0;
  __pyx_pybuffernd_orientations.data = NULL;
  __pyx_pybuffernd_orientations.rcbuffer = &__pyx_pybuffer_orientations;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_orientations.diminfo[0].strides = __pyx_pybuffernd_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_orientations.diminfo[0].shape = __pyx_pybuffernd_orientations.rcbuffer->pybuffer.shape[0];
 670:         """
 671:             charge_left means the number of charges particles left to be set
 672:             orientations means the orientations possible for this particle (OH or H30)
 673:         """
 674: 
 675:         iteration = 1
  /* "water_algorithm_cython.pyx":675
 *         """
 * 
 *         iteration = 1             # <<<<<<<<<<<<<<
 *         while charge_left > 0:
 *             print_parallel("##    Handling charged particle no %i     ##" % (iteration), self.logfile)
 */
  __pyx_v_iteration = 1;
 676:         while charge_left > 0:
  /* "water_algorithm_cython.pyx":676
 * 
 *         iteration = 1
 *         while charge_left > 0:             # <<<<<<<<<<<<<<
 *             print_parallel("##    Handling charged particle no %i     ##" % (iteration), self.logfile)
 *             print_parallel("--------------------------------------------", self.logfile)
 */
  while (1) {
    __pyx_t_1 = (__pyx_v_charge_left > 0);
    if (!__pyx_t_1) break;
 677:             print_parallel("##    Handling charged particle no %i     ##" % (iteration), self.logfile)
    /* "water_algorithm_cython.pyx":677
 *         iteration = 1
 *         while charge_left > 0:
 *             print_parallel("##    Handling charged particle no %i     ##" % (iteration), self.logfile)             # <<<<<<<<<<<<<<
 *             print_parallel("--------------------------------------------", self.logfile)
 *             charge_left -= 1
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_iteration); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_75), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 678:             print_parallel("--------------------------------------------", self.logfile)
    /* "water_algorithm_cython.pyx":678
 *         while charge_left > 0:
 *             print_parallel("##    Handling charged particle no %i     ##" % (iteration), self.logfile)
 *             print_parallel("--------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *             charge_left -= 1
 *             iteration += 1
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_76));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_76));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_76));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 679:             charge_left -= 1
    /* "water_algorithm_cython.pyx":679
 *             print_parallel("##    Handling charged particle no %i     ##" % (iteration), self.logfile)
 *             print_parallel("--------------------------------------------", self.logfile)
 *             charge_left -= 1             # <<<<<<<<<<<<<<
 *             iteration += 1
 *             discarded = 0
 */
    __pyx_v_charge_left = (__pyx_v_charge_left - 1);
 680:             iteration += 1
    /* "water_algorithm_cython.pyx":680
 *             print_parallel("--------------------------------------------", self.logfile)
 *             charge_left -= 1
 *             iteration += 1             # <<<<<<<<<<<<<<
 *             discarded = 0
 *             new_water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 */
    __pyx_v_iteration = (__pyx_v_iteration + 1);
 681:             discarded = 0
    /* "water_algorithm_cython.pyx":681
 *             charge_left -= 1
 *             iteration += 1
 *             discarded = 0             # <<<<<<<<<<<<<<
 *             new_water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 *             if len(water_orientations) == 0:
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_XDECREF(__pyx_v_discarded);
    __pyx_v_discarded = __pyx_int_0;
 682:             new_water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":682
 *             iteration += 1
 *             discarded = 0
 *             new_water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *             if len(water_orientations) == 0:
 *                 if rank == 0:
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_v_new_water_orientations);
    __pyx_v_new_water_orientations = __pyx_t_5;
    __pyx_t_5 = 0;
 683:             if len(water_orientations) == 0:
    /* "water_algorithm_cython.pyx":683
 *             discarded = 0
 *             new_water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 *             if len(water_orientations) == 0:             # <<<<<<<<<<<<<<
 *                 if rank == 0:
 *                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)
 */
    __pyx_t_6 = PyObject_Length(((PyObject *)__pyx_v_water_orientations)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = (__pyx_t_6 == 0);
    if (__pyx_t_1) {
 684:                 if rank == 0:
      /* "water_algorithm_cython.pyx":684
 *             new_water_orientations = np.zeros((0, self.N),  dtype=DTYPE2)
 *             if len(water_orientations) == 0:
 *                 if rank == 0:             # <<<<<<<<<<<<<<
 *                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)
 *                     water_orient.fill(-1)
 */
      __pyx_t_1 = (rank == 0);
      if (__pyx_t_1) {
 685:                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)
        /* "water_algorithm_cython.pyx":685
 *             if len(water_orientations) == 0:
 *                 if rank == 0:
 *                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                     water_orient.fill(-1)
 *                     new_water_orientations, discarded = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_4));
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_v_water_orient);
        __pyx_v_water_orient = __pyx_t_2;
        __pyx_t_2 = 0;
 686:                     water_orient.fill(-1)
        /* "water_algorithm_cython.pyx":686
 *                 if rank == 0:
 *                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)
 *                     water_orient.fill(-1)             # <<<<<<<<<<<<<<
 *                     new_water_orientations, discarded = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_water_orient, __pyx_n_s__fill); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_77), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "water_algorithm_cython.pyx":686
 *                 if rank == 0:
 *                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)
 *                     water_orient.fill(-1)             # <<<<<<<<<<<<<<
 *                     new_water_orientations, discarded = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 */
  __pyx_k_tuple_77 = PyTuple_Pack(1, __pyx_int_neg_1); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_77);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77));
 687:                     new_water_orientations, discarded = self.handle_single_charge(water_orient, new_water_orientations, orientations)
        /* "water_algorithm_cython.pyx":687
 *                     water_orient = np.ndarray((len(self.nearest_neighbors_nos[0])), dtype=DTYPE2)
 *                     water_orient.fill(-1)
 *                     new_water_orientations, discarded = self.handle_single_charge(water_orient, new_water_orientations, orientations)             # <<<<<<<<<<<<<<
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 *             else:
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_78); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_v_water_orient);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_water_orient);
        __Pyx_GIVEREF(__pyx_v_water_orient);
        __Pyx_INCREF(__pyx_v_new_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_new_water_orientations);
        __Pyx_GIVEREF(__pyx_v_new_water_orientations);
        __Pyx_INCREF(((PyObject *)__pyx_v_orientations));
        PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_orientations));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_orientations));
        __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
          PyObject* sequence = __pyx_t_5;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          #else
          __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          #endif
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        {
          Py_ssize_t index = -1;
          __pyx_t_3 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext;
          index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          index = 1; __pyx_t_4 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_7 = NULL;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L8_unpacking_done;
          __pyx_L7_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_7 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L8_unpacking_done:;
        }
        __Pyx_DECREF(__pyx_v_new_water_orientations);
        __pyx_v_new_water_orientations = __pyx_t_2;
        __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_v_discarded);
        __pyx_v_discarded = __pyx_t_4;
        __pyx_t_4 = 0;
 688:                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
        /* "water_algorithm_cython.pyx":688
 *                     water_orient.fill(-1)
 *                     new_water_orientations, discarded = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)             # <<<<<<<<<<<<<<
 *             else:
 *                 water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_v_new_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_new_water_orientations);
        __Pyx_GIVEREF(__pyx_v_new_water_orientations);
        __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
        if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_v_new_water_orientations);
        __pyx_v_new_water_orientations = __pyx_t_3;
        __pyx_t_3 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    /*else*/ {
 689:             else:
 690:                 water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
      /* "water_algorithm_cython.pyx":690
 *                     new_water_orientations = comm.bcast(new_water_orientations,  root = 0)
 *             else:
 *                 water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)             # <<<<<<<<<<<<<<
 *                 for l, water_orient in enumerate(water_orientations):
 *                     new_water_orientations, d = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyInt_FromLong(size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_water_orientations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
        __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_9 < 0)) {
          PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          }
        }
        __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
      __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
 691:                 for l, water_orient in enumerate(water_orientations):
      /* "water_algorithm_cython.pyx":691
 *             else:
 *                 water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
 *                 for l, water_orient in enumerate(water_orientations):             # <<<<<<<<<<<<<<
 *                     new_water_orientations, d = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 *                     discarded += d
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_2 = __pyx_int_0;
      if (PyList_CheckExact(((PyObject *)__pyx_v_water_orientations)) || PyTuple_CheckExact(((PyObject *)__pyx_v_water_orientations))) {
        __pyx_t_4 = ((PyObject *)__pyx_v_water_orientations); __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
        __pyx_t_13 = NULL;
      } else {
        __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_water_orientations)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext;
      }
      for (;;) {
        if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_4)) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_4)) {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          __pyx_t_5 = __pyx_t_13(__pyx_t_4);
          if (unlikely(!__pyx_t_5)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_XDECREF(__pyx_v_water_orient);
        __pyx_v_water_orient = __pyx_t_5;
        __pyx_t_5 = 0;
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XDECREF(__pyx_v_l);
        __pyx_v_l = __pyx_t_2;
        __pyx_t_5 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2);
        __pyx_t_2 = __pyx_t_5;
        __pyx_t_5 = 0;
 692:                     new_water_orientations, d = self.handle_single_charge(water_orient, new_water_orientations, orientations)
        /* "water_algorithm_cython.pyx":692
 *                 water_orientations = comm.scatter(split_list(water_orientations,  size),  root = 0)
 *                 for l, water_orient in enumerate(water_orientations):
 *                     new_water_orientations, d = self.handle_single_charge(water_orient, new_water_orientations, orientations)             # <<<<<<<<<<<<<<
 *                     discarded += d
 *                 new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
 */
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_78); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_water_orient);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_water_orient);
        __Pyx_GIVEREF(__pyx_v_water_orient);
        __Pyx_INCREF(__pyx_v_new_water_orientations);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_new_water_orientations);
        __Pyx_GIVEREF(__pyx_v_new_water_orientations);
        __Pyx_INCREF(((PyObject *)__pyx_v_orientations));
        PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_v_orientations));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_orientations));
        __pyx_t_14 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        if ((likely(PyTuple_CheckExact(__pyx_t_14))) || (PyList_CheckExact(__pyx_t_14))) {
          PyObject* sequence = __pyx_t_14;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          #else
          __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          #endif
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        {
          Py_ssize_t index = -1;
          __pyx_t_15 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_7 = Py_TYPE(__pyx_t_15)->tp_iternext;
          index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_15); if (unlikely(!__pyx_t_3)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_15); if (unlikely(!__pyx_t_5)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_5);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_15), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_7 = NULL;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          goto __pyx_L12_unpacking_done;
          __pyx_L11_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_7 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L12_unpacking_done:;
        }
        __Pyx_DECREF(__pyx_v_new_water_orientations);
        __pyx_v_new_water_orientations = __pyx_t_3;
        __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_v_d);
        __pyx_v_d = __pyx_t_5;
        __pyx_t_5 = 0;
 693:                     discarded += d
        /* "water_algorithm_cython.pyx":693
 *                 for l, water_orient in enumerate(water_orientations):
 *                     new_water_orientations, d = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 *                     discarded += d             # <<<<<<<<<<<<<<
 *                 new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
 *             discarded = gather_and_sum(discarded)
 */
        __pyx_t_14 = PyNumber_InPlaceAdd(__pyx_v_discarded, __pyx_v_d); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_v_discarded);
        __pyx_v_discarded = __pyx_t_14;
        __pyx_t_14 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 694:                 new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
      /* "water_algorithm_cython.pyx":694
 *                     new_water_orientations, d = self.handle_single_charge(water_orient, new_water_orientations, orientations)
 *                     discarded += d
 *                 new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))             # <<<<<<<<<<<<<<
 *             discarded = gather_and_sum(discarded)
 *             print_parallel("Discarded %i geometries due to breakage of ice rules" % (discarded), self.logfile)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_67); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__allgather); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_INCREF(__pyx_v_new_water_orientations);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_new_water_orientations);
      __Pyx_GIVEREF(__pyx_v_new_water_orientations);
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
      __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_v_new_water_orientations);
      __pyx_v_new_water_orientations = __pyx_t_5;
      __pyx_t_5 = 0;
    }
    __pyx_L5:;
 695:             discarded = gather_and_sum(discarded)
    /* "water_algorithm_cython.pyx":695
 *                     discarded += d
 *                 new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
 *             discarded = gather_and_sum(discarded)             # <<<<<<<<<<<<<<
 *             print_parallel("Discarded %i geometries due to breakage of ice rules" % (discarded), self.logfile)
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_sum); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_INCREF(__pyx_v_discarded);
    PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_discarded);
    __Pyx_GIVEREF(__pyx_v_discarded);
    __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_v_discarded);
    __pyx_v_discarded = __pyx_t_2;
    __pyx_t_2 = 0;
 696:             print_parallel("Discarded %i geometries due to breakage of ice rules" % (discarded), self.logfile)
    /* "water_algorithm_cython.pyx":696
 *                 new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations))
 *             discarded = gather_and_sum(discarded)
 *             print_parallel("Discarded %i geometries due to breakage of ice rules" % (discarded), self.logfile)             # <<<<<<<<<<<<<<
 * 
 *             print_(new_water_orientations, self.logfile)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_79), __pyx_v_discarded); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_14));
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_14));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_14));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_14 = 0;
    __pyx_t_14 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
 697: 
 698:             print_(new_water_orientations, self.logfile)
    /* "water_algorithm_cython.pyx":698
 *             print_parallel("Discarded %i geometries due to breakage of ice rules" % (discarded), self.logfile)
 * 
 *             print_(new_water_orientations, self.logfile)             # <<<<<<<<<<<<<<
 *             water_orientations = self.remove_symmetric_results(new_water_orientations,  -1, self.symmetry_operations, -1, [], False, [], None, 20, True) #self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i)
 *             self.print_time_stats()
 */
    __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_new_water_orientations);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_new_water_orientations);
    __Pyx_GIVEREF(__pyx_v_new_water_orientations);
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_2 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 699:             water_orientations = self.remove_symmetric_results(new_water_orientations,  -1, self.symmetry_operations, -1, [], False, [], None, 20, True) #self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i)
    /* "water_algorithm_cython.pyx":699
 * 
 *             print_(new_water_orientations, self.logfile)
 *             water_orientations = self.remove_symmetric_results(new_water_orientations,  -1, self.symmetry_operations, -1, [], False, [], None, 20, True) #self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i)             # <<<<<<<<<<<<<<
 *             self.print_time_stats()
 *         return water_orientations
 */
    __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_new_water_orientations);
    if (unlikely(!__pyx_t_16.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = ((PyObject *)__pyx_v_self->symmetry_operations);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_14 = PyList_New(0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->remove_symmetric_results(__pyx_v_self, __pyx_t_16, -1, ((PyObject*)__pyx_t_2), -1, ((PyObject*)__pyx_t_5), 0, ((PyObject*)__pyx_t_14), ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)Py_None), 20, 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
    __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
 700:             self.print_time_stats()
    /* "water_algorithm_cython.pyx":700
 *             print_(new_water_orientations, self.logfile)
 *             water_orientations = self.remove_symmetric_results(new_water_orientations,  -1, self.symmetry_operations, -1, [], False, [], None, 20, True) #self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i)
 *             self.print_time_stats()             # <<<<<<<<<<<<<<
 *         return water_orientations
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__print_time_stats); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_14 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
 701:         return water_orientations
  /* "water_algorithm_cython.pyx":701
 *             water_orientations = self.remove_symmetric_results(new_water_orientations,  -1, self.symmetry_operations, -1, [], False, [], None, 20, True) #self.remove_symmetries_no_invariants(new_water_orientations,   nearest_neighbors_nos, i)
 *             self.print_time_stats()
 *         return water_orientations             # <<<<<<<<<<<<<<
 * 
 *     def handle_single_charge(self, np.ndarray[DTYPE2_t, ndim=1] water_orient, np.ndarray[DTYPE2_t, ndim=2] water_orientations, np.ndarray[DTYPE2_t, ndim=1] orientations):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
  __pyx_r = ((PyObject *)__pyx_v_water_orientations);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_orientations.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_charge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_orientations.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_discarded);
  __Pyx_XDECREF(__pyx_v_new_water_orientations);
  __Pyx_XDECREF(__pyx_v_water_orient);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientations);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_41handle_single_charge(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_41handle_single_charge(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_water_orient = 0;
  PyArrayObject *__pyx_v_water_orientations = 0;
  PyArrayObject *__pyx_v_orientations = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_single_charge (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_orient,&__pyx_n_s__water_orientations,&__pyx_n_s__orientations,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orient)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("handle_single_charge", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__orientations)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("handle_single_charge", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "handle_single_charge") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_water_orient = ((PyArrayObject *)values[0]);
    __pyx_v_water_orientations = ((PyArrayObject *)values[1]);
    __pyx_v_orientations = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_single_charge", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_single_charge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_water_orient), __pyx_ptype_5numpy_ndarray, 1, "water_orient", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_water_orientations), __pyx_ptype_5numpy_ndarray, 1, "water_orientations", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_orientations), __pyx_ptype_5numpy_ndarray, 1, "orientations", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_40handle_single_charge(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_water_orient, __pyx_v_water_orientations, __pyx_v_orientations);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 702: 
 703:     def handle_single_charge(self, np.ndarray[DTYPE2_t, ndim=1] water_orient, np.ndarray[DTYPE2_t, ndim=2] water_orientations, np.ndarray[DTYPE2_t, ndim=1] orientations):
/* "water_algorithm_cython.pyx":703
 *         return water_orientations
 * 
 *     def handle_single_charge(self, np.ndarray[DTYPE2_t, ndim=1] water_orient, np.ndarray[DTYPE2_t, ndim=2] water_orientations, np.ndarray[DTYPE2_t, ndim=1] orientations):             # <<<<<<<<<<<<<<
 *         cdef int discarded = 0, i, coodination_number
 *         cdef DTYPE2_t orientation
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_40handle_single_charge(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyArrayObject *__pyx_v_water_orient, PyArrayObject *__pyx_v_water_orientations, PyArrayObject *__pyx_v_orientations) {
  int __pyx_v_discarded;
  int __pyx_v_i;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_orientation;
  PyObject *__pyx_v_coordination_number = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_water_orientations_trial = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_orientations;
  __Pyx_Buffer __pyx_pybuffer_orientations;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orient;
  __Pyx_Buffer __pyx_pybuffer_water_orient;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_single_charge", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_water_orientations);
  __pyx_pybuffer_water_orient.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orient.refcount = 0;
  __pyx_pybuffernd_water_orient.data = NULL;
  __pyx_pybuffernd_water_orient.rcbuffer = &__pyx_pybuffer_water_orient;
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
  __pyx_pybuffer_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_orientations.refcount = 0;
  __pyx_pybuffernd_orientations.data = NULL;
  __pyx_pybuffernd_orientations.rcbuffer = &__pyx_pybuffer_orientations;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orient, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orient.diminfo[0].strides = __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orient.diminfo[0].shape = __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_orientations.diminfo[0].strides = __pyx_pybuffernd_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_orientations.diminfo[0].shape = __pyx_pybuffernd_orientations.rcbuffer->pybuffer.shape[0];
 704:         cdef int discarded = 0, i, coodination_number
  /* "water_algorithm_cython.pyx":704
 * 
 *     def handle_single_charge(self, np.ndarray[DTYPE2_t, ndim=1] water_orient, np.ndarray[DTYPE2_t, ndim=2] water_orientations, np.ndarray[DTYPE2_t, ndim=1] orientations):
 *         cdef int discarded = 0, i, coodination_number             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t orientation
 *         for i in range(len(self.oxygen_coordinates)):
 */
  __pyx_v_discarded = 0;
 705:         cdef DTYPE2_t orientation
 706:         for i in range(len(self.oxygen_coordinates)):
  /* "water_algorithm_cython.pyx":706
 *         cdef int discarded = 0, i, coodination_number
 *         cdef DTYPE2_t orientation
 *         for i in range(len(self.oxygen_coordinates)):             # <<<<<<<<<<<<<<
 *             coordination_number = self.get_coordination_number(i)
 *             if water_orient[i] != -1 or (coordination_number == 4 and orientations[0] > 9):
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->oxygen_coordinates);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
 707:             coordination_number = self.get_coordination_number(i)
    /* "water_algorithm_cython.pyx":707
 *         cdef DTYPE2_t orientation
 *         for i in range(len(self.oxygen_coordinates)):
 *             coordination_number = self.get_coordination_number(i)             # <<<<<<<<<<<<<<
 *             if water_orient[i] != -1 or (coordination_number == 4 and orientations[0] > 9):
 *                 continue
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_80); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_coordination_number);
    __pyx_v_coordination_number = __pyx_t_4;
    __pyx_t_4 = 0;
 708:             if water_orient[i] != -1 or (coordination_number == 4 and orientations[0] > 9):
    /* "water_algorithm_cython.pyx":708
 *         for i in range(len(self.oxygen_coordinates)):
 *             coordination_number = self.get_coordination_number(i)
 *             if water_orient[i] != -1 or (coordination_number == 4 and orientations[0] > 9):             # <<<<<<<<<<<<<<
 *                 continue
 *             for orientation in orientations:
 */
    __pyx_t_6 = __pyx_v_i;
    __pyx_t_7 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_water_orient.diminfo[0].strides)) != -1);
    if (!__pyx_t_7) {
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_coordination_number, __pyx_int_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_8) {
        __pyx_t_9 = 0;
        __pyx_t_10 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_orientations.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_orientations.diminfo[0].strides)) > 9);
        __pyx_t_11 = __pyx_t_10;
      } else {
        __pyx_t_11 = __pyx_t_8;
      }
      __pyx_t_8 = __pyx_t_11;
    } else {
      __pyx_t_8 = __pyx_t_7;
    }
    if (__pyx_t_8) {
 709:                 continue
      /* "water_algorithm_cython.pyx":709
 *             coordination_number = self.get_coordination_number(i)
 *             if water_orient[i] != -1 or (coordination_number == 4 and orientations[0] > 9):
 *                 continue             # <<<<<<<<<<<<<<
 *             for orientation in orientations:
 *                 s = time()
 */
      goto __pyx_L3_continue;
      goto __pyx_L5;
    }
    __pyx_L5:;
 710:             for orientation in orientations:
    /* "water_algorithm_cython.pyx":710
 *             if water_orient[i] != -1 or (coordination_number == 4 and orientations[0] > 9):
 *                 continue
 *             for orientation in orientations:             # <<<<<<<<<<<<<<
 *                 s = time()
 *                 if self.water_orientation_is_valid(orientation, water_orient, i):
 */
    if (PyList_CheckExact(((PyObject *)__pyx_v_orientations)) || PyTuple_CheckExact(((PyObject *)__pyx_v_orientations))) {
      __pyx_t_4 = ((PyObject *)__pyx_v_orientations); __Pyx_INCREF(__pyx_t_4); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_orientations)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_5 = __pyx_t_13(__pyx_t_4);
        if (unlikely(!__pyx_t_5)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_5);
      }
      __pyx_t_14 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_5); if (unlikely((__pyx_t_14 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_orientation = __pyx_t_14;
 711:                 s = time()
      /* "water_algorithm_cython.pyx":711
 *                 continue
 *             for orientation in orientations:
 *                 s = time()             # <<<<<<<<<<<<<<
 *                 if self.water_orientation_is_valid(orientation, water_orient, i):
 *                     water_orientations_trial = np.copy(water_orient)
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_v_s);
      __pyx_v_s = __pyx_t_1;
      __pyx_t_1 = 0;
 712:                 if self.water_orientation_is_valid(orientation, water_orient, i):
      /* "water_algorithm_cython.pyx":712
 *             for orientation in orientations:
 *                 s = time()
 *                 if self.water_orientation_is_valid(orientation, water_orient, i):             # <<<<<<<<<<<<<<
 *                     water_orientations_trial = np.copy(water_orient)
 *                     water_orientations_trial[i] = orientation
 */
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->water_orientation_is_valid(__pyx_v_self, __pyx_v_orientation, ((PyArrayObject *)__pyx_v_water_orient), __pyx_v_i)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_8) {
 713:                     water_orientations_trial = np.copy(water_orient)
        /* "water_algorithm_cython.pyx":713
 *                 s = time()
 *                 if self.water_orientation_is_valid(orientation, water_orient, i):
 *                     water_orientations_trial = np.copy(water_orient)             # <<<<<<<<<<<<<<
 *                     water_orientations_trial[i] = orientation
 *                     water_orientations = np.vstack((water_orientations,  water_orientations_trial))
 */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__copy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(((PyObject *)__pyx_v_water_orient));
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_water_orient));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orient));
        __pyx_t_15 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_v_water_orientations_trial);
        __pyx_v_water_orientations_trial = __pyx_t_15;
        __pyx_t_15 = 0;
 714:                     water_orientations_trial[i] = orientation
        /* "water_algorithm_cython.pyx":714
 *                 if self.water_orientation_is_valid(orientation, water_orient, i):
 *                     water_orientations_trial = np.copy(water_orient)
 *                     water_orientations_trial[i] = orientation             # <<<<<<<<<<<<<<
 *                     water_orientations = np.vstack((water_orientations,  water_orientations_trial))
 *                 else:
 */
        __pyx_t_15 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_orientation); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        if (__Pyx_SetItemInt(__pyx_v_water_orientations_trial, __pyx_v_i, __pyx_t_15, sizeof(int), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
 715:                     water_orientations = np.vstack((water_orientations,  water_orientations_trial))
        /* "water_algorithm_cython.pyx":715
 *                     water_orientations_trial = np.copy(water_orient)
 *                     water_orientations_trial[i] = orientation
 *                     water_orientations = np.vstack((water_orientations,  water_orientations_trial))             # <<<<<<<<<<<<<<
 *                 else:
 *                     discarded += 1
 */
        __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s__vstack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
        PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_water_orientations));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
        __Pyx_INCREF(__pyx_v_water_orientations_trial);
        PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_water_orientations_trial);
        __Pyx_GIVEREF(__pyx_v_water_orientations_trial);
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_15));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_15));
        __pyx_t_15 = 0;
        __pyx_t_15 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_16 = ((PyArrayObject *)__pyx_t_15);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
          __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_17 < 0)) {
            PyErr_Fetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_20);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
            }
          }
          __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_16 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
        __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_15);
        __pyx_t_15 = 0;
        goto __pyx_L8;
      }
      /*else*/ {
 716:                 else:
 717:                     discarded += 1
        /* "water_algorithm_cython.pyx":717
 *                     water_orientations = np.vstack((water_orientations,  water_orientations_trial))
 *                 else:
 *                     discarded += 1             # <<<<<<<<<<<<<<
 *                 self.iteration_time += time()-s
 *         return water_orientations, discarded
 */
        __pyx_v_discarded = (__pyx_v_discarded + 1);
      }
      __pyx_L8:;
 718:                 self.iteration_time += time()-s
      /* "water_algorithm_cython.pyx":718
 *                 else:
 *                     discarded += 1
 *                 self.iteration_time += time()-s             # <<<<<<<<<<<<<<
 *         return water_orientations, discarded
 * 
 */
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Subtract(__pyx_t_1, __pyx_v_s); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_15, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__iteration_time, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_L3_continue:;
  }
 719:         return water_orientations, discarded
  /* "water_algorithm_cython.pyx":719
 *                     discarded += 1
 *                 self.iteration_time += time()-s
 *         return water_orientations, discarded             # <<<<<<<<<<<<<<
 * 
 *     def calculate_possible_combinations(self, DTYPE2_t molecule_no):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_discarded); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_water_orientations));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_15);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_orientations.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_single_charge", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_orientations.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_coordination_number);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_water_orientations_trial);
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientations);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_43calculate_possible_combinations(PyObject *__pyx_v_self, PyObject *__pyx_arg_molecule_no); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_43calculate_possible_combinations(PyObject *__pyx_v_self, PyObject *__pyx_arg_molecule_no) {
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_molecule_no;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("calculate_possible_combinations (wrapper)", 0);
  assert(__pyx_arg_molecule_no); {
    __pyx_v_molecule_no = __Pyx_PyInt_from_py_npy_int8(__pyx_arg_molecule_no); if (unlikely((__pyx_v_molecule_no == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.calculate_possible_combinations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_42calculate_possible_combinations(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((__pyx_t_22water_algorithm_cython_DTYPE2_t)__pyx_v_molecule_no));
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 720: 
 721:     def calculate_possible_combinations(self, DTYPE2_t molecule_no):
/* "water_algorithm_cython.pyx":721
 *         return water_orientations, discarded
 * 
 *     def calculate_possible_combinations(self, DTYPE2_t molecule_no):             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_42calculate_possible_combinations(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_molecule_no) {
  PyArrayObject *__pyx_v_nn = 0;
  PyArrayObject *__pyx_v_trial = 0;
  PyArrayObject *__pyx_v_empty_water_orient = 0;
  PyArrayObject *__pyx_v_result = 0;
  int __pyx_v_wo;
  int __pyx_v_i;
  int __pyx_v_neighbor_no;
  int __pyx_v_N;
  int __pyx_v_all_impossible;
  int __pyx_v_allowed_by_preset;
  PyObject *__pyx_v_allowed_by_presets = 0;
  long __pyx_v_wo_2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_empty_water_orient;
  __Pyx_Buffer __pyx_pybuffer_empty_water_orient;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nn;
  __Pyx_Buffer __pyx_pybuffer_nn;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_trial;
  __Pyx_Buffer __pyx_pybuffer_trial;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("calculate_possible_combinations", 0);
  __pyx_pybuffer_nn.pybuffer.buf = NULL;
  __pyx_pybuffer_nn.refcount = 0;
  __pyx_pybuffernd_nn.data = NULL;
  __pyx_pybuffernd_nn.rcbuffer = &__pyx_pybuffer_nn;
  __pyx_pybuffer_trial.pybuffer.buf = NULL;
  __pyx_pybuffer_trial.refcount = 0;
  __pyx_pybuffernd_trial.data = NULL;
  __pyx_pybuffernd_trial.rcbuffer = &__pyx_pybuffer_trial;
  __pyx_pybuffer_empty_water_orient.pybuffer.buf = NULL;
  __pyx_pybuffer_empty_water_orient.refcount = 0;
  __pyx_pybuffernd_empty_water_orient.data = NULL;
  __pyx_pybuffernd_empty_water_orient.rcbuffer = &__pyx_pybuffer_empty_water_orient;
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
 722:         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
  /* "water_algorithm_cython.pyx":722
 * 
 *     def calculate_possible_combinations(self, DTYPE2_t molecule_no):
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)
 *         empty_water_orient.fill(-1)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_nn = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_3 = 0;
  __pyx_v_nn = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 723:         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":723
 *     def calculate_possible_combinations(self, DTYPE2_t molecule_no):
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         empty_water_orient.fill(-1)
 *         cdef np.ndarray[DTYPE_t, ndim=3] result = np.ndarray((nn.shape[0], 6, 6), dtype=DTYPE)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_empty_water_orient.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_empty_water_orient = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_empty_water_orient.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_empty_water_orient.diminfo[0].strides = __pyx_pybuffernd_empty_water_orient.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_empty_water_orient.diminfo[0].shape = __pyx_pybuffernd_empty_water_orient.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_v_empty_water_orient = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 724:         empty_water_orient.fill(-1)
  /* "water_algorithm_cython.pyx":724
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)
 *         empty_water_orient.fill(-1)             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=3] result = np.ndarray((nn.shape[0], 6, 6), dtype=DTYPE)
 *         cdef int wo, i, neighbor_no, N = nn.shape[0]
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_empty_water_orient), __pyx_n_s__fill); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_81), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "water_algorithm_cython.pyx":724
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)
 *         empty_water_orient.fill(-1)             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=3] result = np.ndarray((nn.shape[0], 6, 6), dtype=DTYPE)
 *         cdef int wo, i, neighbor_no, N = nn.shape[0]
 */
  __pyx_k_tuple_81 = PyTuple_Pack(1, __pyx_int_neg_1); if (unlikely(!__pyx_k_tuple_81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_81);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_81));
 725:         cdef np.ndarray[DTYPE_t, ndim=3] result = np.ndarray((nn.shape[0], 6, 6), dtype=DTYPE)
  /* "water_algorithm_cython.pyx":725
 *         cdef np.ndarray[DTYPE2_t, ndim=1] trial, empty_water_orient = np.ndarray( self.nearest_neighbors_nos[0].shape[0], dtype=DTYPE2)
 *         empty_water_orient.fill(-1)
 *         cdef np.ndarray[DTYPE_t, ndim=3] result = np.ndarray((nn.shape[0], 6, 6), dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         cdef int wo, i, neighbor_no, N = nn.shape[0]
 *         cdef bint all_impossible, allowed_by_preset
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_nn->dimensions[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_6);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_6);
  __Pyx_GIVEREF(__pyx_int_6);
  __Pyx_INCREF(__pyx_int_6);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_6);
  __Pyx_GIVEREF(__pyx_int_6);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_result = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_result.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_result.diminfo[2].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_result.diminfo[2].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 726:         cdef int wo, i, neighbor_no, N = nn.shape[0]
  /* "water_algorithm_cython.pyx":726
 *         empty_water_orient.fill(-1)
 *         cdef np.ndarray[DTYPE_t, ndim=3] result = np.ndarray((nn.shape[0], 6, 6), dtype=DTYPE)
 *         cdef int wo, i, neighbor_no, N = nn.shape[0]             # <<<<<<<<<<<<<<
 *         cdef bint all_impossible, allowed_by_preset
 *         cdef list allowed_by_presets = []
 */
  __pyx_v_N = (__pyx_v_nn->dimensions[0]);
 727:         cdef bint all_impossible, allowed_by_preset
 728:         cdef list allowed_by_presets = []
  /* "water_algorithm_cython.pyx":728
 *         cdef int wo, i, neighbor_no, N = nn.shape[0]
 *         cdef bint all_impossible, allowed_by_preset
 *         cdef list allowed_by_presets = []             # <<<<<<<<<<<<<<
 *         for wo from 0 <= wo < 6:
 *             allowed_by_preset = self.wo_is_allowed_by_preset_bonds(molecule_no, wo)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_allowed_by_presets = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 729:         for wo from 0 <= wo < 6:
  /* "water_algorithm_cython.pyx":729
 *         cdef bint all_impossible, allowed_by_preset
 *         cdef list allowed_by_presets = []
 *         for wo from 0 <= wo < 6:             # <<<<<<<<<<<<<<
 *             allowed_by_preset = self.wo_is_allowed_by_preset_bonds(molecule_no, wo)
 *             allowed_by_presets.append(allowed_by_preset)
 */
  for (__pyx_v_wo = 0; __pyx_v_wo < 6; __pyx_v_wo++) {
 730:             allowed_by_preset = self.wo_is_allowed_by_preset_bonds(molecule_no, wo)
    /* "water_algorithm_cython.pyx":730
 *         cdef list allowed_by_presets = []
 *         for wo from 0 <= wo < 6:
 *             allowed_by_preset = self.wo_is_allowed_by_preset_bonds(molecule_no, wo)             # <<<<<<<<<<<<<<
 *             allowed_by_presets.append(allowed_by_preset)
 *             #if not allowed_by_preset:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_82); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyInt_FromLong(__pyx_v_wo); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_allowed_by_preset = __pyx_t_6;
 731:             allowed_by_presets.append(allowed_by_preset)
    /* "water_algorithm_cython.pyx":731
 *         for wo from 0 <= wo < 6:
 *             allowed_by_preset = self.wo_is_allowed_by_preset_bonds(molecule_no, wo)
 *             allowed_by_presets.append(allowed_by_preset)             # <<<<<<<<<<<<<<
 *             #if not allowed_by_preset:
 *             #    print "Bond %i - %i, wo %i not allowed by preset" % (molecule_no, neighbor_no, wo)
 */
    __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_allowed_by_preset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_allowed_by_presets, __pyx_t_2); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
 732:             #if not allowed_by_preset:
 733:             #    print "Bond %i - %i, wo %i not allowed by preset" % (molecule_no, neighbor_no, wo)
 734:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":734
 *             #if not allowed_by_preset:
 *             #    print "Bond %i - %i, wo %i not allowed by preset" % (molecule_no, neighbor_no, wo)
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             neighbor_no = nn[i]
 *             for wo from 0 <= wo < 6:
 */
  __pyx_t_8 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {
 735:             neighbor_no = nn[i]
    /* "water_algorithm_cython.pyx":735
 *             #    print "Bond %i - %i, wo %i not allowed by preset" % (molecule_no, neighbor_no, wo)
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]             # <<<<<<<<<<<<<<
 *             for wo from 0 <= wo < 6:
 *                 all_impossible = self.wo_is_equal_with_any_of_previous_wos(molecule_no, wo)
 */
    __pyx_t_9 = __pyx_v_i;
    __pyx_v_neighbor_no = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_nn.diminfo[0].strides));
 736:             for wo from 0 <= wo < 6:
    /* "water_algorithm_cython.pyx":736
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]
 *             for wo from 0 <= wo < 6:             # <<<<<<<<<<<<<<
 *                 all_impossible = self.wo_is_equal_with_any_of_previous_wos(molecule_no, wo)
 *                 allowed_by_preset = allowed_by_presets[wo]
 */
    for (__pyx_v_wo = 0; __pyx_v_wo < 6; __pyx_v_wo++) {
 737:                 all_impossible = self.wo_is_equal_with_any_of_previous_wos(molecule_no, wo)
      /* "water_algorithm_cython.pyx":737
 *             neighbor_no = nn[i]
 *             for wo from 0 <= wo < 6:
 *                 all_impossible = self.wo_is_equal_with_any_of_previous_wos(molecule_no, wo)             # <<<<<<<<<<<<<<
 *                 allowed_by_preset = allowed_by_presets[wo]
 *                 for wo_2 from 0 <= wo_2 < 6:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_83); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyInt_FromLong(__pyx_v_wo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_5 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_all_impossible = __pyx_t_6;
 738:                 allowed_by_preset = allowed_by_presets[wo]
      /* "water_algorithm_cython.pyx":738
 *             for wo from 0 <= wo < 6:
 *                 all_impossible = self.wo_is_equal_with_any_of_previous_wos(molecule_no, wo)
 *                 allowed_by_preset = allowed_by_presets[wo]             # <<<<<<<<<<<<<<
 *                 for wo_2 from 0 <= wo_2 < 6:
 *                     trial = empty_water_orient.copy()
 */
      __pyx_t_6 = __Pyx_PyObject_IsTrue(PyList_GET_ITEM(__pyx_v_allowed_by_presets, __pyx_v_wo)); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_allowed_by_preset = __pyx_t_6;
 739:                 for wo_2 from 0 <= wo_2 < 6:
      /* "water_algorithm_cython.pyx":739
 *                 all_impossible = self.wo_is_equal_with_any_of_previous_wos(molecule_no, wo)
 *                 allowed_by_preset = allowed_by_presets[wo]
 *                 for wo_2 from 0 <= wo_2 < 6:             # <<<<<<<<<<<<<<
 *                     trial = empty_water_orient.copy()
 *                     trial[neighbor_no] = wo_2
 */
      for (__pyx_v_wo_2 = 0; __pyx_v_wo_2 < 6; __pyx_v_wo_2++) {
 740:                     trial = empty_water_orient.copy()
        /* "water_algorithm_cython.pyx":740
 *                 allowed_by_preset = allowed_by_presets[wo]
 *                 for wo_2 from 0 <= wo_2 < 6:
 *                     trial = empty_water_orient.copy()             # <<<<<<<<<<<<<<
 *                     trial[neighbor_no] = wo_2
 *                     if not all_impossible and allowed_by_preset and self.water_orientation_is_valid(wo, trial, molecule_no):
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_empty_water_orient), __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = ((PyArrayObject *)__pyx_t_4);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trial.rcbuffer->pybuffer);
          __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trial.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_11 < 0)) {
            PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_trial.rcbuffer->pybuffer, (PyObject*)__pyx_v_trial, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            }
          }
          __pyx_pybuffernd_trial.diminfo[0].strides = __pyx_pybuffernd_trial.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_trial.diminfo[0].shape = __pyx_pybuffernd_trial.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_10 = 0;
        __Pyx_XDECREF(((PyObject *)__pyx_v_trial));
        __pyx_v_trial = ((PyArrayObject *)__pyx_t_4);
        __pyx_t_4 = 0;
 741:                     trial[neighbor_no] = wo_2
        /* "water_algorithm_cython.pyx":741
 *                 for wo_2 from 0 <= wo_2 < 6:
 *                     trial = empty_water_orient.copy()
 *                     trial[neighbor_no] = wo_2             # <<<<<<<<<<<<<<
 *                     if not all_impossible and allowed_by_preset and self.water_orientation_is_valid(wo, trial, molecule_no):
 *                         result[i][wo][wo_2] = 1
 */
        __pyx_t_11 = __pyx_v_neighbor_no;
        *__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_trial.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_trial.diminfo[0].strides) = __pyx_v_wo_2;
 742:                     if not all_impossible and allowed_by_preset and self.water_orientation_is_valid(wo, trial, molecule_no):
        /* "water_algorithm_cython.pyx":742
 *                     trial = empty_water_orient.copy()
 *                     trial[neighbor_no] = wo_2
 *                     if not all_impossible and allowed_by_preset and self.water_orientation_is_valid(wo, trial, molecule_no):             # <<<<<<<<<<<<<<
 *                         result[i][wo][wo_2] = 1
 *                     else:
 */
        __pyx_t_6 = (!__pyx_v_all_impossible);
        if (__pyx_t_6) {
          __pyx_t_15 = __pyx_v_allowed_by_preset;
          if (__pyx_t_15) {
            __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->water_orientation_is_valid(__pyx_v_self, __pyx_v_wo, ((PyArrayObject *)__pyx_v_trial), __pyx_v_molecule_no)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_17 = __pyx_t_16;
          } else {
            __pyx_t_17 = __pyx_t_15;
          }
          __pyx_t_15 = __pyx_t_17;
        } else {
          __pyx_t_15 = __pyx_t_6;
        }
        if (__pyx_t_15) {
 743:                         result[i][wo][wo_2] = 1
          /* "water_algorithm_cython.pyx":743
 *                     trial[neighbor_no] = wo_2
 *                     if not all_impossible and allowed_by_preset and self.water_orientation_is_valid(wo, trial, molecule_no):
 *                         result[i][wo][wo_2] = 1             # <<<<<<<<<<<<<<
 *                     else:
 *                         result[i][wo][wo_2] = 0
 */
          __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_wo, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__Pyx_SetItemInt(__pyx_t_1, __pyx_v_wo_2, __pyx_int_1, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L11;
        }
        /*else*/ {
 744:                     else:
 745:                         result[i][wo][wo_2] = 0
          /* "water_algorithm_cython.pyx":745
 *                         result[i][wo][wo_2] = 1
 *                     else:
 *                         result[i][wo][wo_2] = 0             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
          __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_wo, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__Pyx_SetItemInt(__pyx_t_4, __pyx_v_wo_2, __pyx_int_0, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __pyx_L11:;
      }
    }
  }
 746:         return result
  /* "water_algorithm_cython.pyx":746
 *                     else:
 *                         result[i][wo][wo_2] = 0
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def preset_bonds_list_to_dict(self, list preset_bonds_list):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_empty_water_orient.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trial.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.calculate_possible_combinations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_empty_water_orient.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_trial.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __Pyx_XDECREF((PyObject *)__pyx_v_trial);
  __Pyx_XDECREF((PyObject *)__pyx_v_empty_water_orient);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_allowed_by_presets);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_45preset_bonds_list_to_dict(PyObject *__pyx_v_self, PyObject *__pyx_v_preset_bonds_list); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_44preset_bonds_list_to_dict[] = "\n            Converts preset bonds list to dict, the input list has to be\n            two dimensional and the second dimension must have either 3 or 4 values\n            where first and second are the molecules of the bond and the last is the value\n            of the bond.\n        ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_45preset_bonds_list_to_dict(PyObject *__pyx_v_self, PyObject *__pyx_v_preset_bonds_list) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("preset_bonds_list_to_dict (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_preset_bonds_list), (&PyList_Type), 1, "preset_bonds_list", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_44preset_bonds_list_to_dict(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject*)__pyx_v_preset_bonds_list));
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 747: 
 748:     def preset_bonds_list_to_dict(self, list preset_bonds_list):
/* "water_algorithm_cython.pyx":748
 *         return result
 * 
 *     def preset_bonds_list_to_dict(self, list preset_bonds_list):             # <<<<<<<<<<<<<<
 *         """
 *             Converts preset bonds list to dict, the input list has to be
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_44preset_bonds_list_to_dict(CYTHON_UNUSED struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_preset_bonds_list) {
  PyObject *__pyx_v_result = 0;
  PyObject *__pyx_v_p = NULL;
  PyObject *__pyx_v_sys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("preset_bonds_list_to_dict", 0);
 749:         """
 750:             Converts preset bonds list to dict, the input list has to be
 751:             two dimensional and the second dimension must have either 3 or 4 values
 752:             where first and second are the molecules of the bond and the last is the value
 753:             of the bond.
 754:         """
 755:         cdef dict result = None
  /* "water_algorithm_cython.pyx":755
 *             of the bond.
 *         """
 *         cdef dict result = None             # <<<<<<<<<<<<<<
 *         if preset_bonds_list != None:
 *             result = {}
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_result = ((PyObject*)Py_None);
 756:         if preset_bonds_list != None:
  /* "water_algorithm_cython.pyx":756
 *         """
 *         cdef dict result = None
 *         if preset_bonds_list != None:             # <<<<<<<<<<<<<<
 *             result = {}
 *             for p in preset_bonds_list:
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_preset_bonds_list), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
 757:             result = {}
    /* "water_algorithm_cython.pyx":757
 *         cdef dict result = None
 *         if preset_bonds_list != None:
 *             result = {}             # <<<<<<<<<<<<<<
 *             for p in preset_bonds_list:
 *                 if len(p) < 3 or len(p) > 4:
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_v_result));
    __pyx_v_result = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
 758:             for p in preset_bonds_list:
    /* "water_algorithm_cython.pyx":758
 *         if preset_bonds_list != None:
 *             result = {}
 *             for p in preset_bonds_list:             # <<<<<<<<<<<<<<
 *                 if len(p) < 3 or len(p) > 4:
 *                     import sys
 */
    if (unlikely(((PyObject *)__pyx_v_preset_bonds_list) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = ((PyObject *)__pyx_v_preset_bonds_list); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      __Pyx_XDECREF(__pyx_v_p);
      __pyx_v_p = __pyx_t_4;
      __pyx_t_4 = 0;
 759:                 if len(p) < 3 or len(p) > 4:
      /* "water_algorithm_cython.pyx":759
 *             result = {}
 *             for p in preset_bonds_list:
 *                 if len(p) < 3 or len(p) > 4:             # <<<<<<<<<<<<<<
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bonds list value (%s) is of the wrong size." % p)
 */
      __pyx_t_5 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = (__pyx_t_5 < 3);
      if (!__pyx_t_2) {
        __pyx_t_5 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_6 = (__pyx_t_5 > 4);
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_2;
      }
      if (__pyx_t_7) {
 760:                     import sys
        /* "water_algorithm_cython.pyx":760
 *             for p in preset_bonds_list:
 *                 if len(p) < 3 or len(p) > 4:
 *                     import sys             # <<<<<<<<<<<<<<
 *                     sys.exit("Invalid preset bonds: The preset bonds list value (%s) is of the wrong size." % p)
 *                 if len(p) == 3 and p[2] != 1 and p[2] != -1:
 */
        __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_XDECREF(__pyx_v_sys);
        __pyx_v_sys = __pyx_t_4;
        __pyx_t_4 = 0;
 761:                     sys.exit("Invalid preset bonds: The preset bonds list value (%s) is of the wrong size." % p)
        /* "water_algorithm_cython.pyx":761
 *                 if len(p) < 3 or len(p) > 4:
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bonds list value (%s) is of the wrong size." % p)             # <<<<<<<<<<<<<<
 *                 if len(p) == 3 and p[2] != 1 and p[2] != -1:
 *                     import sys
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_sys, __pyx_n_s__exit); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_84), __pyx_v_p); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
        __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
 762:                 if len(p) == 3 and p[2] != 1 and p[2] != -1:
      /* "water_algorithm_cython.pyx":762
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bonds list value (%s) is of the wrong size." % p)
 *                 if len(p) == 3 and p[2] != 1 and p[2] != -1:             # <<<<<<<<<<<<<<
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1]))
 */
      __pyx_t_5 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = (__pyx_t_5 == 3);
      if (__pyx_t_7) {
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = PyObject_RichCompare(__pyx_t_8, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (__pyx_t_2) {
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_10 = __pyx_t_6;
        } else {
          __pyx_t_10 = __pyx_t_2;
        }
        __pyx_t_2 = __pyx_t_10;
      } else {
        __pyx_t_2 = __pyx_t_7;
      }
      if (__pyx_t_2) {
 763:                     import sys
        /* "water_algorithm_cython.pyx":763
 *                     sys.exit("Invalid preset bonds: The preset bonds list value (%s) is of the wrong size." % p)
 *                 if len(p) == 3 and p[2] != 1 and p[2] != -1:
 *                     import sys             # <<<<<<<<<<<<<<
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1]))
 *                 if len(p) == 4 and p[3] != 1 and p[3] != -1:
 */
        __pyx_t_8 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_XDECREF(__pyx_v_sys);
        __pyx_v_sys = __pyx_t_8;
        __pyx_t_8 = 0;
 764:                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1]))
        /* "water_algorithm_cython.pyx":764
 *                 if len(p) == 3 and p[2] != 1 and p[2] != -1:
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1]))             # <<<<<<<<<<<<<<
 *                 if len(p) == 4 and p[3] != 1 and p[3] != -1:
 *                     import sys
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_sys, __pyx_n_s__exit); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_9 = 0;
        __pyx_t_4 = 0;
        __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_85), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_11));
        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
        __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_t_11));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_11));
        __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L7;
      }
      __pyx_L7:;
 765:                 if len(p) == 4 and p[3] != 1 and p[3] != -1:
      /* "water_algorithm_cython.pyx":765
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1]))
 *                 if len(p) == 4 and p[3] != 1 and p[3] != -1:             # <<<<<<<<<<<<<<
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i_%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1], p[2]))
 */
      __pyx_t_5 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = (__pyx_t_5 == 4);
      if (__pyx_t_2) {
        __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 3, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = PyObject_RichCompare(__pyx_t_11, __pyx_int_1, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (__pyx_t_7) {
          __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_p, 3, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_11 = PyObject_RichCompare(__pyx_t_12, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_6 = __pyx_t_10;
        } else {
          __pyx_t_6 = __pyx_t_7;
        }
        __pyx_t_7 = __pyx_t_6;
      } else {
        __pyx_t_7 = __pyx_t_2;
      }
      if (__pyx_t_7) {
 766:                     import sys
        /* "water_algorithm_cython.pyx":766
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1]))
 *                 if len(p) == 4 and p[3] != 1 and p[3] != -1:
 *                     import sys             # <<<<<<<<<<<<<<
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i_%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1], p[2]))
 *                 if p[0] not in result:
 */
        __pyx_t_11 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_XDECREF(__pyx_v_sys);
        __pyx_v_sys = __pyx_t_11;
        __pyx_t_11 = 0;
 767:                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i_%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1], p[2]))
        /* "water_algorithm_cython.pyx":767
 *                 if len(p) == 4 and p[3] != 1 and p[3] != -1:
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i_%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1], p[2]))             # <<<<<<<<<<<<<<
 *                 if p[0] not in result:
 *                     result[p[0]] = {}
 */
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_sys, __pyx_n_s__exit); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_9);
        __pyx_t_12 = 0;
        __pyx_t_8 = 0;
        __pyx_t_4 = 0;
        __pyx_t_9 = 0;
        __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_86), ((PyObject *)__pyx_t_13)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
        __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
        __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)__pyx_t_9));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
        __pyx_t_9 = 0;
        __pyx_t_9 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L8;
      }
      __pyx_L8:;
 768:                 if p[0] not in result:
      /* "water_algorithm_cython.pyx":768
 *                     import sys
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i_%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1], p[2]))
 *                 if p[0] not in result:             # <<<<<<<<<<<<<<
 *                     result[p[0]] = {}
 *                 if p[1] not in result[p[0]]:
 */
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = (__Pyx_PyDict_Contains(__pyx_t_9, ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (__pyx_t_7) {
 769:                     result[p[0]] = {}
        /* "water_algorithm_cython.pyx":769
 *                     sys.exit("Invalid preset bonds: The preset bond value (%i) for bond (%i-%i_%i) is not valid. The value should be 1 or -1 but." % (p[2], p[0], p[1], p[2]))
 *                 if p[0] not in result:
 *                     result[p[0]] = {}             # <<<<<<<<<<<<<<
 *                 if p[1] not in result[p[0]]:
 *                     if len(p) == 4:
 */
        __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_9));
        __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_t_13, ((PyObject *)__pyx_t_9)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        goto __pyx_L9;
      }
      __pyx_L9:;
 770:                 if p[1] not in result[p[0]]:
      /* "water_algorithm_cython.pyx":770
 *                 if p[0] not in result:
 *                     result[p[0]] = {}
 *                 if p[1] not in result[p[0]]:             # <<<<<<<<<<<<<<
 *                     if len(p) == 4:
 *                         result[p[0]][p[1]] = {}
 */
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_11 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_13); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_7 = (__Pyx_PySequence_Contains(__pyx_t_9, __pyx_t_11, Py_NE)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (__pyx_t_7) {
 771:                     if len(p) == 4:
        /* "water_algorithm_cython.pyx":771
 *                     result[p[0]] = {}
 *                 if p[1] not in result[p[0]]:
 *                     if len(p) == 4:             # <<<<<<<<<<<<<<
 *                         result[p[0]][p[1]] = {}
 *                         result[p[0]][p[1]][p[2]] = p[3]
 */
        __pyx_t_5 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = (__pyx_t_5 == 4);
        if (__pyx_t_7) {
 772:                         result[p[0]][p[1]] = {}
          /* "water_algorithm_cython.pyx":772
 *                 if p[1] not in result[p[0]]:
 *                     if len(p) == 4:
 *                         result[p[0]][p[1]] = {}             # <<<<<<<<<<<<<<
 *                         result[p[0]][p[1]][p[2]] = p[3]
 *                     else:
 */
          __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_11));
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_13 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_9); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          if (PyObject_SetItem(__pyx_t_13, __pyx_t_9, ((PyObject *)__pyx_t_11)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
 773:                         result[p[0]][p[1]][p[2]] = p[3]
          /* "water_algorithm_cython.pyx":773
 *                     if len(p) == 4:
 *                         result[p[0]][p[1]] = {}
 *                         result[p[0]][p[1]][p[2]] = p[3]             # <<<<<<<<<<<<<<
 *                     else:
 *                         result[p[0]][p[1]] = p[2]
 */
          __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 3, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_13 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_9); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_4 = PyObject_GetItem(__pyx_t_13, __pyx_t_9); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          if (PyObject_SetItem(__pyx_t_4, __pyx_t_9, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          goto __pyx_L11;
        }
        /*else*/ {
 774:                     else:
 775:                         result[p[0]][p[1]] = p[2]
          /* "water_algorithm_cython.pyx":775
 *                         result[p[0]][p[1]][p[2]] = p[3]
 *                     else:
 *                         result[p[0]][p[1]] = p[2]             # <<<<<<<<<<<<<<
 *                 else:
 *                     if len(p) == 4:
 */
          __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_9); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          if (PyObject_SetItem(__pyx_t_4, __pyx_t_9, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __pyx_L11:;
        goto __pyx_L10;
      }
      /*else*/ {
 776:                 else:
 777:                     if len(p) == 4:
        /* "water_algorithm_cython.pyx":777
 *                         result[p[0]][p[1]] = p[2]
 *                 else:
 *                     if len(p) == 4:             # <<<<<<<<<<<<<<
 *                         result[p[0]][p[1]][p[2]] = p[3]
 *                     else:
 */
        __pyx_t_5 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = (__pyx_t_5 == 4);
        if (__pyx_t_7) {
 778:                         result[p[0]][p[1]][p[2]] = p[3]
          /* "water_algorithm_cython.pyx":778
 *                 else:
 *                     if len(p) == 4:
 *                         result[p[0]][p[1]][p[2]] = p[3]             # <<<<<<<<<<<<<<
 *                     else:
 *                         result[p[0]][p[1]] = p[3]
 */
          __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 3, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_4 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_9); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_13 = PyObject_GetItem(__pyx_t_4, __pyx_t_9); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          if (PyObject_SetItem(__pyx_t_13, __pyx_t_9, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          goto __pyx_L12;
        }
        /*else*/ {
 779:                     else:
 780:                         result[p[0]][p[1]] = p[3]
          /* "water_algorithm_cython.pyx":780
 *                         result[p[0]][p[1]][p[2]] = p[3]
 *                     else:
 *                         result[p[0]][p[1]] = p[3]             # <<<<<<<<<<<<<<
 *                         #raise Exception("There are two values for same bond in preset bonds list")
 * 
 */
          __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 3, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_13 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_t_9); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_p, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          if (PyObject_SetItem(__pyx_t_13, __pyx_t_9, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __pyx_L12:;
      }
      __pyx_L10:;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 781:                         #raise Exception("There are two values for same bond in preset bonds list")
 782: 
 783:         return result
  /* "water_algorithm_cython.pyx":783
 *                         #raise Exception("There are two values for same bond in preset bonds list")
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.preset_bonds_list_to_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_p);
  __Pyx_XDECREF(__pyx_v_sys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_47wo_is_allowed_by_preset_bonds(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_47wo_is_allowed_by_preset_bonds(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_molecule_no;
  int __pyx_v_water_orientation;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wo_is_allowed_by_preset_bonds (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__molecule_no,&__pyx_n_s__water_orientation,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__molecule_no)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("wo_is_allowed_by_preset_bonds", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wo_is_allowed_by_preset_bonds") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_molecule_no = __Pyx_PyInt_from_py_npy_int8(values[0]); if (unlikely((__pyx_v_molecule_no == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_water_orientation = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_water_orientation == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wo_is_allowed_by_preset_bonds", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.wo_is_allowed_by_preset_bonds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_46wo_is_allowed_by_preset_bonds(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_molecule_no, __pyx_v_water_orientation);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 784: 
 785: 
 786: 
 787: 
 788:     def wo_is_allowed_by_preset_bonds(self, DTYPE2_t molecule_no,  int water_orientation):
/* "water_algorithm_cython.pyx":788
 * 
 * 
 *     def wo_is_allowed_by_preset_bonds(self, DTYPE2_t molecule_no,  int water_orientation):             # <<<<<<<<<<<<<<
 *         if self.preset_bond_values == None:
 *             return True
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_46wo_is_allowed_by_preset_bonds(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_molecule_no, int __pyx_v_water_orientation) {
  __Pyx_memviewslice __pyx_v_bvv = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_nn = 0;
  PyArrayObject *__pyx_v_nnp = 0;
  CYTHON_UNUSED PyObject *__pyx_v_ones = 0;
  int __pyx_v_found;
  int __pyx_v_i;
  int __pyx_v_k;
  CYTHON_UNUSED int __pyx_v_wo;
  int __pyx_v_N;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_neighbor_no;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nn;
  __Pyx_Buffer __pyx_pybuffer_nn;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nnp;
  __Pyx_Buffer __pyx_pybuffer_nnp;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wo_is_allowed_by_preset_bonds", 0);
  __pyx_pybuffer_nn.pybuffer.buf = NULL;
  __pyx_pybuffer_nn.refcount = 0;
  __pyx_pybuffernd_nn.data = NULL;
  __pyx_pybuffernd_nn.rcbuffer = &__pyx_pybuffer_nn;
  __pyx_pybuffer_nnp.pybuffer.buf = NULL;
  __pyx_pybuffer_nnp.refcount = 0;
  __pyx_pybuffernd_nnp.data = NULL;
  __pyx_pybuffernd_nnp.rcbuffer = &__pyx_pybuffer_nnp;
 789:         if self.preset_bond_values == None:
  /* "water_algorithm_cython.pyx":789
 * 
 *     def wo_is_allowed_by_preset_bonds(self, DTYPE2_t molecule_no,  int water_orientation):
 *         if self.preset_bond_values == None:             # <<<<<<<<<<<<<<
 *             return True
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
 790:             return True
    /* "water_algorithm_cython.pyx":790
 *     def wo_is_allowed_by_preset_bonds(self, DTYPE2_t molecule_no,  int water_orientation):
 *         if self.preset_bond_values == None:
 *             return True             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 791:         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
  /* "water_algorithm_cython.pyx":791
 *         if self.preset_bond_values == None:
 *             return True
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE_t, ndim=1] nnp = self.nearest_neighbors_nos[2][molecule_no]
 */
  __pyx_t_4 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_water_orientation); if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_bvv = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 792:         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
  /* "water_algorithm_cython.pyx":792
 *             return True
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=1] nnp = self.nearest_neighbors_nos[2][molecule_no]
 *         cdef list ones = []
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_nn = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_nn = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 793:         cdef np.ndarray[DTYPE_t, ndim=1] nnp = self.nearest_neighbors_nos[2][molecule_no]
  /* "water_algorithm_cython.pyx":793
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE_t, ndim=1] nnp = self.nearest_neighbors_nos[2][molecule_no]             # <<<<<<<<<<<<<<
 *         cdef list ones = []
 *         cdef bint equals, found
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_nnp = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nnp.diminfo[0].strides = __pyx_pybuffernd_nnp.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nnp.diminfo[0].shape = __pyx_pybuffernd_nnp.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_nnp = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 794:         cdef list ones = []
  /* "water_algorithm_cython.pyx":794
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE_t, ndim=1] nnp = self.nearest_neighbors_nos[2][molecule_no]
 *         cdef list ones = []             # <<<<<<<<<<<<<<
 *         cdef bint equals, found
 *         cdef int i, j, k, wo = 0, N = bvv.shape[0]
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ones = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
 795:         cdef bint equals, found
 796:         cdef int i, j, k, wo = 0, N = bvv.shape[0]
  /* "water_algorithm_cython.pyx":796
 *         cdef list ones = []
 *         cdef bint equals, found
 *         cdef int i, j, k, wo = 0, N = bvv.shape[0]             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t neighbor_no
 *         for k from 0 <= k < N:
 */
  __pyx_v_wo = 0;
  __pyx_v_N = (__pyx_v_bvv.shape[0]);
 797:         cdef DTYPE2_t neighbor_no
 798:         for k from 0 <= k < N:
  /* "water_algorithm_cython.pyx":798
 *         cdef int i, j, k, wo = 0, N = bvv.shape[0]
 *         cdef DTYPE2_t neighbor_no
 *         for k from 0 <= k < N:             # <<<<<<<<<<<<<<
 *             neighbor_no = nn[k]
 *             if molecule_no in self.preset_bond_values and neighbor_no in self.preset_bond_values[molecule_no]:
 */
  __pyx_t_7 = __pyx_v_N;
  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {
 799:             neighbor_no = nn[k]
    /* "water_algorithm_cython.pyx":799
 *         cdef DTYPE2_t neighbor_no
 *         for k from 0 <= k < N:
 *             neighbor_no = nn[k]             # <<<<<<<<<<<<<<
 *             if molecule_no in self.preset_bond_values and neighbor_no in self.preset_bond_values[molecule_no]:
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 */
    __pyx_t_8 = __pyx_v_k;
    __pyx_v_neighbor_no = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_nn.diminfo[0].strides));
 800:             if molecule_no in self.preset_bond_values and neighbor_no in self.preset_bond_values[molecule_no]:
    /* "water_algorithm_cython.pyx":800
 *         for k from 0 <= k < N:
 *             neighbor_no = nn[k]
 *             if molecule_no in self.preset_bond_values and neighbor_no in self.preset_bond_values[molecule_no]:             # <<<<<<<<<<<<<<
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 */
    __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_t_2, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {
      __pyx_t_1 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_neighbor_no); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_10 = (__Pyx_PySequence_Contains(__pyx_t_1, __pyx_t_9, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __pyx_t_10;
    } else {
      __pyx_t_11 = __pyx_t_3;
    }
    if (__pyx_t_11) {
 801:                 nn = self.nearest_neighbors_nos[0, molecule_no]
      /* "water_algorithm_cython.pyx":801
 *             neighbor_no = nn[k]
 *             if molecule_no in self.preset_bond_values and neighbor_no in self.preset_bond_values[molecule_no]:
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]             # <<<<<<<<<<<<<<
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 *                 found = False
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_GetItem(__pyx_t_9, ((PyObject *)__pyx_t_2)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
        __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_12 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_v_nn, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          }
        }
        __pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_nn));
      __pyx_v_nn = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;
 802:                 nnp = self.nearest_neighbors_nos[2, molecule_no]
      /* "water_algorithm_cython.pyx":802
 *             if molecule_no in self.preset_bond_values and neighbor_no in self.preset_bond_values[molecule_no]:
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]             # <<<<<<<<<<<<<<
 *                 found = False
 *                 for i from 0 <= i < N:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_t_9)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer);
        __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_12 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer, (PyObject*)__pyx_v_nnp, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_nnp.diminfo[0].strides = __pyx_pybuffernd_nnp.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nnp.diminfo[0].shape = __pyx_pybuffernd_nnp.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_nnp));
      __pyx_v_nnp = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
 803:                 found = False
      /* "water_algorithm_cython.pyx":803
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 *                 found = False             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < N:
 *                     if not found and nn[i] == neighbor_no:
 */
      __pyx_v_found = 0;
 804:                 for i from 0 <= i < N:
      /* "water_algorithm_cython.pyx":804
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 *                 found = False
 *                 for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *                     if not found and nn[i] == neighbor_no:
 *                         if (type(self.preset_bond_values[molecule_no][neighbor_no]) == dict and nnp[i] in self.preset_bond_values[molecule_no][neighbor_no]):
 */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) {
 805:                     if not found and nn[i] == neighbor_no:
        /* "water_algorithm_cython.pyx":805
 *                 found = False
 *                 for i from 0 <= i < N:
 *                     if not found and nn[i] == neighbor_no:             # <<<<<<<<<<<<<<
 *                         if (type(self.preset_bond_values[molecule_no][neighbor_no]) == dict and nnp[i] in self.preset_bond_values[molecule_no][neighbor_no]):
 *                             found = True
 */
        __pyx_t_11 = (!__pyx_v_found);
        if (__pyx_t_11) {
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_3 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_nn.diminfo[0].strides)) == __pyx_v_neighbor_no);
          __pyx_t_10 = __pyx_t_3;
        } else {
          __pyx_t_10 = __pyx_t_11;
        }
        if (__pyx_t_10) {
 806:                         if (type(self.preset_bond_values[molecule_no][neighbor_no]) == dict and nnp[i] in self.preset_bond_values[molecule_no][neighbor_no]):
          /* "water_algorithm_cython.pyx":806
 *                 for i from 0 <= i < N:
 *                     if not found and nn[i] == neighbor_no:
 *                         if (type(self.preset_bond_values[molecule_no][neighbor_no]) == dict and nnp[i] in self.preset_bond_values[molecule_no][neighbor_no]):             # <<<<<<<<<<<<<<
 *                             found = True
 *                             if (bvv[i] != self.preset_bond_values[molecule_no][neighbor_no][nnp[i]]):
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_2)), ((PyObject *)((PyObject*)(&PyDict_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_10) {
            __pyx_t_17 = __pyx_v_i;
            __pyx_t_9 = __Pyx_PyInt_to_py_npy_uint8((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_nnp.diminfo[0].strides))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_11 = (__Pyx_PySequence_Contains(__pyx_t_9, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_3 = __pyx_t_11;
          } else {
            __pyx_t_3 = __pyx_t_10;
          }
          if (__pyx_t_3) {
 807:                             found = True
            /* "water_algorithm_cython.pyx":807
 *                     if not found and nn[i] == neighbor_no:
 *                         if (type(self.preset_bond_values[molecule_no][neighbor_no]) == dict and nnp[i] in self.preset_bond_values[molecule_no][neighbor_no]):
 *                             found = True             # <<<<<<<<<<<<<<
 *                             if (bvv[i] != self.preset_bond_values[molecule_no][neighbor_no][nnp[i]]):
 *                                 return False
 */
            __pyx_v_found = 1;
 808:                             if (bvv[i] != self.preset_bond_values[molecule_no][neighbor_no][nnp[i]]):
            /* "water_algorithm_cython.pyx":808
 *                         if (type(self.preset_bond_values[molecule_no][neighbor_no]) == dict and nnp[i] in self.preset_bond_values[molecule_no][neighbor_no]):
 *                             found = True
 *                             if (bvv[i] != self.preset_bond_values[molecule_no][neighbor_no][nnp[i]]):             # <<<<<<<<<<<<<<
 *                                 return False
 *                         elif (type(self.preset_bond_values[molecule_no][neighbor_no]) != dict and nnp[i] == 13):
 */
            __pyx_t_18 = __pyx_v_i;
            __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_18)) )))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_19 = __pyx_v_i;
            __pyx_t_20 = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_nnp.diminfo[0].strides));
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, __pyx_t_20, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_9 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (__pyx_t_3) {
 809:                                 return False
              /* "water_algorithm_cython.pyx":809
 *                             found = True
 *                             if (bvv[i] != self.preset_bond_values[molecule_no][neighbor_no][nnp[i]]):
 *                                 return False             # <<<<<<<<<<<<<<
 *                         elif (type(self.preset_bond_values[molecule_no][neighbor_no]) != dict and nnp[i] == 13):
 *                             found = True
 */
              __Pyx_XDECREF(__pyx_r);
              __pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_r = __pyx_t_9;
              __pyx_t_9 = 0;
              goto __pyx_L0;
              goto __pyx_L11;
            }
            __pyx_L11:;
            goto __pyx_L10;
          }
 810:                         elif (type(self.preset_bond_values[molecule_no][neighbor_no]) != dict and nnp[i] == 13):
          /* "water_algorithm_cython.pyx":810
 *                             if (bvv[i] != self.preset_bond_values[molecule_no][neighbor_no][nnp[i]]):
 *                                 return False
 *                         elif (type(self.preset_bond_values[molecule_no][neighbor_no]) != dict and nnp[i] == 13):             # <<<<<<<<<<<<<<
 *                             found = True
 *                             if bvv[i] != self.preset_bond_values[molecule_no][neighbor_no]:
 */
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_9)), ((PyObject *)((PyObject*)(&PyDict_Type))), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_3) {
            __pyx_t_21 = __pyx_v_i;
            __pyx_t_10 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_nnp.diminfo[0].strides)) == 13);
            __pyx_t_11 = __pyx_t_10;
          } else {
            __pyx_t_11 = __pyx_t_3;
          }
          if (__pyx_t_11) {
 811:                             found = True
            /* "water_algorithm_cython.pyx":811
 *                                 return False
 *                         elif (type(self.preset_bond_values[molecule_no][neighbor_no]) != dict and nnp[i] == 13):
 *                             found = True             # <<<<<<<<<<<<<<
 *                             if bvv[i] != self.preset_bond_values[molecule_no][neighbor_no]:
 *                                 return False
 */
            __pyx_v_found = 1;
 812:                             if bvv[i] != self.preset_bond_values[molecule_no][neighbor_no]:
            /* "water_algorithm_cython.pyx":812
 *                         elif (type(self.preset_bond_values[molecule_no][neighbor_no]) != dict and nnp[i] == 13):
 *                             found = True
 *                             if bvv[i] != self.preset_bond_values[molecule_no][neighbor_no]:             # <<<<<<<<<<<<<<
 *                                 return False
 * 
 */
            __pyx_t_22 = __pyx_v_i;
            __pyx_t_1 = __Pyx_PyInt_to_py_npy_int8((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_22)) )))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_9, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__pyx_t_11) {
 813:                                 return False
              /* "water_algorithm_cython.pyx":813
 *                             found = True
 *                             if bvv[i] != self.preset_bond_values[molecule_no][neighbor_no]:
 *                                 return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
              __Pyx_XDECREF(__pyx_r);
              __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_r = __pyx_t_2;
              __pyx_t_2 = 0;
              goto __pyx_L0;
              goto __pyx_L12;
            }
            __pyx_L12:;
            goto __pyx_L10;
          }
          __pyx_L10:;
          goto __pyx_L9;
        }
        __pyx_L9:;
      }
      goto __pyx_L6;
    }
 814: 
 815: 
 816:             elif neighbor_no in self.preset_bond_values and molecule_no in self.preset_bond_values[neighbor_no]:
    /* "water_algorithm_cython.pyx":816
 * 
 * 
 *             elif neighbor_no in self.preset_bond_values and molecule_no in self.preset_bond_values[neighbor_no]:             # <<<<<<<<<<<<<<
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 */
    __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_neighbor_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = (__Pyx_PySequence_Contains(__pyx_t_2, __pyx_t_9, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_11) {
      __pyx_t_9 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_t_9, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = __pyx_t_3;
    } else {
      __pyx_t_10 = __pyx_t_11;
    }
    if (__pyx_t_10) {
 817:                 nn = self.nearest_neighbors_nos[0, molecule_no]
      /* "water_algorithm_cython.pyx":817
 * 
 *             elif neighbor_no in self.preset_bond_values and molecule_no in self.preset_bond_values[neighbor_no]:
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]             # <<<<<<<<<<<<<<
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 *                 for i from 0 <= i < N:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_t_2)); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
        __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_12 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_v_nn, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
          }
        }
        __pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_nn));
      __pyx_v_nn = ((PyArrayObject *)__pyx_t_9);
      __pyx_t_9 = 0;
 818:                 nnp = self.nearest_neighbors_nos[2, molecule_no]
      /* "water_algorithm_cython.pyx":818
 *             elif neighbor_no in self.preset_bond_values and molecule_no in self.preset_bond_values[neighbor_no]:
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < N:
 *                     if nn[i] == neighbor_no:
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(__pyx_t_9, ((PyObject *)__pyx_t_1)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer);
        __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_12 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer, (PyObject*)__pyx_v_nnp, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_nnp.diminfo[0].strides = __pyx_pybuffernd_nnp.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nnp.diminfo[0].shape = __pyx_pybuffernd_nnp.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_nnp));
      __pyx_v_nnp = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
 819:                 for i from 0 <= i < N:
      /* "water_algorithm_cython.pyx":819
 *                 nn = self.nearest_neighbors_nos[0, molecule_no]
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 *                 for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *                     if nn[i] == neighbor_no:
 *                         if (type(self.preset_bond_values[neighbor_no][molecule_no]) == dict and  get_opposite_periodicity_axis_number(nnp[i]) in self.preset_bond_values[neighbor_no][molecule_no]):
 */
      __pyx_t_12 = __pyx_v_N;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) {
 820:                     if nn[i] == neighbor_no:
        /* "water_algorithm_cython.pyx":820
 *                 nnp = self.nearest_neighbors_nos[2, molecule_no]
 *                 for i from 0 <= i < N:
 *                     if nn[i] == neighbor_no:             # <<<<<<<<<<<<<<
 *                         if (type(self.preset_bond_values[neighbor_no][molecule_no]) == dict and  get_opposite_periodicity_axis_number(nnp[i]) in self.preset_bond_values[neighbor_no][molecule_no]):
 *                             if (bvv[i] == self.preset_bond_values[neighbor_no][molecule_no][nnp[i]]):
 */
        __pyx_t_23 = __pyx_v_i;
        __pyx_t_10 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_nn.diminfo[0].strides)) == __pyx_v_neighbor_no);
        if (__pyx_t_10) {
 821:                         if (type(self.preset_bond_values[neighbor_no][molecule_no]) == dict and  get_opposite_periodicity_axis_number(nnp[i]) in self.preset_bond_values[neighbor_no][molecule_no]):
          /* "water_algorithm_cython.pyx":821
 *                 for i from 0 <= i < N:
 *                     if nn[i] == neighbor_no:
 *                         if (type(self.preset_bond_values[neighbor_no][molecule_no]) == dict and  get_opposite_periodicity_axis_number(nnp[i]) in self.preset_bond_values[neighbor_no][molecule_no]):             # <<<<<<<<<<<<<<
 *                             if (bvv[i] == self.preset_bond_values[neighbor_no][molecule_no][nnp[i]]):
 *                                 return False
 */
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_2)), ((PyObject *)((PyObject*)(&PyDict_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_10) {
            __pyx_t_24 = __pyx_v_i;
            __pyx_t_1 = __Pyx_PyInt_to_py_npy_uint8(__pyx_f_22water_algorithm_cython_get_opposite_periodicity_axis_number((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_nnp.diminfo[0].strides)))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_11 = (__Pyx_PySequence_Contains(__pyx_t_1, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_3 = __pyx_t_11;
          } else {
            __pyx_t_3 = __pyx_t_10;
          }
          if (__pyx_t_3) {
 822:                             if (bvv[i] == self.preset_bond_values[neighbor_no][molecule_no][nnp[i]]):
            /* "water_algorithm_cython.pyx":822
 *                     if nn[i] == neighbor_no:
 *                         if (type(self.preset_bond_values[neighbor_no][molecule_no]) == dict and  get_opposite_periodicity_axis_number(nnp[i]) in self.preset_bond_values[neighbor_no][molecule_no]):
 *                             if (bvv[i] == self.preset_bond_values[neighbor_no][molecule_no][nnp[i]]):             # <<<<<<<<<<<<<<
 *                                 return False
 *                         elif (type(self.preset_bond_values[neighbor_no][molecule_no]) != dict and nnp[i] == 13):
 */
            __pyx_t_25 = __pyx_v_i;
            __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_25)) )))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_26 = __pyx_v_i;
            __pyx_t_20 = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_nnp.diminfo[0].strides));
            __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, __pyx_t_20, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (__pyx_t_3) {
 823:                                 return False
              /* "water_algorithm_cython.pyx":823
 *                         if (type(self.preset_bond_values[neighbor_no][molecule_no]) == dict and  get_opposite_periodicity_axis_number(nnp[i]) in self.preset_bond_values[neighbor_no][molecule_no]):
 *                             if (bvv[i] == self.preset_bond_values[neighbor_no][molecule_no][nnp[i]]):
 *                                 return False             # <<<<<<<<<<<<<<
 *                         elif (type(self.preset_bond_values[neighbor_no][molecule_no]) != dict and nnp[i] == 13):
 *                             if bvv[i] == self.preset_bond_values[neighbor_no][molecule_no]:
 */
              __Pyx_XDECREF(__pyx_r);
              __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_r = __pyx_t_1;
              __pyx_t_1 = 0;
              goto __pyx_L0;
              goto __pyx_L17;
            }
            __pyx_L17:;
            goto __pyx_L16;
          }
 824:                         elif (type(self.preset_bond_values[neighbor_no][molecule_no]) != dict and nnp[i] == 13):
          /* "water_algorithm_cython.pyx":824
 *                             if (bvv[i] == self.preset_bond_values[neighbor_no][molecule_no][nnp[i]]):
 *                                 return False
 *                         elif (type(self.preset_bond_values[neighbor_no][molecule_no]) != dict and nnp[i] == 13):             # <<<<<<<<<<<<<<
 *                             if bvv[i] == self.preset_bond_values[neighbor_no][molecule_no]:
 *                                 return False
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_9 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_1)), ((PyObject *)((PyObject*)(&PyDict_Type))), Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_3) {
            __pyx_t_27 = __pyx_v_i;
            __pyx_t_10 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nnp.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_nnp.diminfo[0].strides)) == 13);
            __pyx_t_11 = __pyx_t_10;
          } else {
            __pyx_t_11 = __pyx_t_3;
          }
          if (__pyx_t_11) {
 825:                             if bvv[i] == self.preset_bond_values[neighbor_no][molecule_no]:
            /* "water_algorithm_cython.pyx":825
 *                                 return False
 *                         elif (type(self.preset_bond_values[neighbor_no][molecule_no]) != dict and nnp[i] == 13):
 *                             if bvv[i] == self.preset_bond_values[neighbor_no][molecule_no]:             # <<<<<<<<<<<<<<
 *                                 return False
 *         return True
 */
            __pyx_t_28 = __pyx_v_i;
            __pyx_t_9 = __Pyx_PyInt_to_py_npy_int8((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_28)) )))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__preset_bond_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE2_t), __Pyx_PyInt_to_py_npy_int8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = PyObject_RichCompare(__pyx_t_9, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__pyx_t_11) {
 826:                                 return False
              /* "water_algorithm_cython.pyx":826
 *                         elif (type(self.preset_bond_values[neighbor_no][molecule_no]) != dict and nnp[i] == 13):
 *                             if bvv[i] == self.preset_bond_values[neighbor_no][molecule_no]:
 *                                 return False             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
              __Pyx_XDECREF(__pyx_r);
              __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_r = __pyx_t_2;
              __pyx_t_2 = 0;
              goto __pyx_L0;
              goto __pyx_L18;
            }
            __pyx_L18:;
            goto __pyx_L16;
          }
          __pyx_L16:;
          goto __pyx_L15;
        }
        __pyx_L15:;
      }
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
 827:         return True
  /* "water_algorithm_cython.pyx":827
 *                             if bvv[i] == self.preset_bond_values[neighbor_no][molecule_no]:
 *                                 return False
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def wo_is_equal_with_any_of_previous_wos(self, DTYPE2_t molecule_no, int water_orientation):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_XDECREF(__pyx_t_9);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.wo_is_allowed_by_preset_bonds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nnp.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __Pyx_XDECREF((PyObject *)__pyx_v_nnp);
  __Pyx_XDECREF(__pyx_v_ones);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_49wo_is_equal_with_any_of_previous_wos(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_49wo_is_equal_with_any_of_previous_wos(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_molecule_no;
  int __pyx_v_water_orientation;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wo_is_equal_with_any_of_previous_wos (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__molecule_no,&__pyx_n_s__water_orientation,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__molecule_no)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("wo_is_equal_with_any_of_previous_wos", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wo_is_equal_with_any_of_previous_wos") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_molecule_no = __Pyx_PyInt_from_py_npy_int8(values[0]); if (unlikely((__pyx_v_molecule_no == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_water_orientation = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_water_orientation == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("wo_is_equal_with_any_of_previous_wos", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.wo_is_equal_with_any_of_previous_wos", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_48wo_is_equal_with_any_of_previous_wos(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_molecule_no, __pyx_v_water_orientation);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 828: 
 829:     def wo_is_equal_with_any_of_previous_wos(self, DTYPE2_t molecule_no, int water_orientation):
/* "water_algorithm_cython.pyx":829
 *         return True
 * 
 *     def wo_is_equal_with_any_of_previous_wos(self, DTYPE2_t molecule_no, int water_orientation):             # <<<<<<<<<<<<<<
 *         cdef int coordination_number = self.get_coordination_number(molecule_no)
 *         cdef DTYPE2_t[::1] nbbv, bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_48wo_is_equal_with_any_of_previous_wos(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_molecule_no, int __pyx_v_water_orientation) {
  int __pyx_v_coordination_number;
  __Pyx_memviewslice __pyx_v_nbbv = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_bvv = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_ones = 0;
  int __pyx_v_equals;
  int __pyx_v_i;
  int __pyx_v_wo;
  int __pyx_v_N;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wo_is_equal_with_any_of_previous_wos", 0);
 830:         cdef int coordination_number = self.get_coordination_number(molecule_no)
  /* "water_algorithm_cython.pyx":830
 * 
 *     def wo_is_equal_with_any_of_previous_wos(self, DTYPE2_t molecule_no, int water_orientation):
 *         cdef int coordination_number = self.get_coordination_number(molecule_no)             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] nbbv, bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef list ones = []
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_80); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_coordination_number = __pyx_t_4;
 831:         cdef DTYPE2_t[::1] nbbv, bvv = get_bond_variable_values_from_water_orientation(water_orientation)
  /* "water_algorithm_cython.pyx":831
 *     def wo_is_equal_with_any_of_previous_wos(self, DTYPE2_t molecule_no, int water_orientation):
 *         cdef int coordination_number = self.get_coordination_number(molecule_no)
 *         cdef DTYPE2_t[::1] nbbv, bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         cdef list ones = []
 *         cdef bint equals
 */
  __pyx_t_5 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_water_orientation); if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_bvv = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
 832:         cdef list ones = []
  /* "water_algorithm_cython.pyx":832
 *         cdef int coordination_number = self.get_coordination_number(molecule_no)
 *         cdef DTYPE2_t[::1] nbbv, bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef list ones = []             # <<<<<<<<<<<<<<
 *         cdef bint equals
 *         cdef int i, wo = 0, N = bvv.shape[0]
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_ones = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
 833:         cdef bint equals
 834:         cdef int i, wo = 0, N = bvv.shape[0]
  /* "water_algorithm_cython.pyx":834
 *         cdef list ones = []
 *         cdef bint equals
 *         cdef int i, wo = 0, N = bvv.shape[0]             # <<<<<<<<<<<<<<
 *         if coordination_number < 3:
 *             for i in xrange(N):
 */
  __pyx_v_wo = 0;
  __pyx_v_N = (__pyx_v_bvv.shape[0]);
 835:         if coordination_number < 3:
  /* "water_algorithm_cython.pyx":835
 *         cdef bint equals
 *         cdef int i, wo = 0, N = bvv.shape[0]
 *         if coordination_number < 3:             # <<<<<<<<<<<<<<
 *             for i in xrange(N):
 *                 if bvv[i] == 1:
 */
  __pyx_t_6 = (__pyx_v_coordination_number < 3);
  if (__pyx_t_6) {
 836:             for i in xrange(N):
    /* "water_algorithm_cython.pyx":836
 *         cdef int i, wo = 0, N = bvv.shape[0]
 *         if coordination_number < 3:
 *             for i in xrange(N):             # <<<<<<<<<<<<<<
 *                 if bvv[i] == 1:
 *                     ones.append(self.nearest_neighbors_nos[0, molecule_no, i])
 */
    __pyx_t_4 = __pyx_v_N;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_4; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;
 837:                 if bvv[i] == 1:
      /* "water_algorithm_cython.pyx":837
 *         if coordination_number < 3:
 *             for i in xrange(N):
 *                 if bvv[i] == 1:             # <<<<<<<<<<<<<<
 *                     ones.append(self.nearest_neighbors_nos[0, molecule_no, i])
 *             while wo < water_orientation:
 */
      __pyx_t_8 = __pyx_v_i;
      __pyx_t_6 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_8)) ))) == 1);
      if (__pyx_t_6) {
 838:                     ones.append(self.nearest_neighbors_nos[0, molecule_no, i])
        /* "water_algorithm_cython.pyx":838
 *             for i in xrange(N):
 *                 if bvv[i] == 1:
 *                     ones.append(self.nearest_neighbors_nos[0, molecule_no, i])             # <<<<<<<<<<<<<<
 *             while wo < water_orientation:
 *                 equals = True
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_3 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_GetItem(__pyx_t_2, ((PyObject *)__pyx_t_9)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
        __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_ones, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;
    }
 839:             while wo < water_orientation:
    /* "water_algorithm_cython.pyx":839
 *                 if bvv[i] == 1:
 *                     ones.append(self.nearest_neighbors_nos[0, molecule_no, i])
 *             while wo < water_orientation:             # <<<<<<<<<<<<<<
 *                 equals = True
 *                 nbbv = get_bond_variable_values_from_water_orientation(wo)
 */
    while (1) {
      __pyx_t_6 = (__pyx_v_wo < __pyx_v_water_orientation);
      if (!__pyx_t_6) break;
 840:                 equals = True
      /* "water_algorithm_cython.pyx":840
 *                     ones.append(self.nearest_neighbors_nos[0, molecule_no, i])
 *             while wo < water_orientation:
 *                 equals = True             # <<<<<<<<<<<<<<
 *                 nbbv = get_bond_variable_values_from_water_orientation(wo)
 *                 for i in xrange(N):
 */
      __pyx_v_equals = 1;
 841:                 nbbv = get_bond_variable_values_from_water_orientation(wo)
      /* "water_algorithm_cython.pyx":841
 *             while wo < water_orientation:
 *                 equals = True
 *                 nbbv = get_bond_variable_values_from_water_orientation(wo)             # <<<<<<<<<<<<<<
 *                 for i in xrange(N):
 *                     if nbbv[i] == 1 and self.nearest_neighbors_nos[0, molecule_no, i] not in ones:
 */
      __pyx_t_5 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_wo); if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __PYX_XDEC_MEMVIEW(&__pyx_v_nbbv, 1);
      __pyx_v_nbbv = __pyx_t_5;
      __pyx_t_5.memview = NULL;
      __pyx_t_5.data = NULL;
 842:                 for i in xrange(N):
      /* "water_algorithm_cython.pyx":842
 *                 equals = True
 *                 nbbv = get_bond_variable_values_from_water_orientation(wo)
 *                 for i in xrange(N):             # <<<<<<<<<<<<<<
 *                     if nbbv[i] == 1 and self.nearest_neighbors_nos[0, molecule_no, i] not in ones:
 *                         equals = False
 */
      __pyx_t_4 = __pyx_v_N;
      for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_4; __pyx_t_7+=1) {
        __pyx_v_i = __pyx_t_7;
 843:                     if nbbv[i] == 1 and self.nearest_neighbors_nos[0, molecule_no, i] not in ones:
        /* "water_algorithm_cython.pyx":843
 *                 nbbv = get_bond_variable_values_from_water_orientation(wo)
 *                 for i in xrange(N):
 *                     if nbbv[i] == 1 and self.nearest_neighbors_nos[0, molecule_no, i] not in ones:             # <<<<<<<<<<<<<<
 *                         equals = False
 *                         break
 */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_6 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_nbbv.data) + __pyx_t_11)) ))) == 1);
        if (__pyx_t_6) {
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_9 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_molecule_no); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_INCREF(__pyx_int_0);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_9 = 0;
          __pyx_t_2 = 0;
          __pyx_t_2 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_t_3)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_t_12 = (__Pyx_PySequence_Contains(__pyx_t_2, ((PyObject *)__pyx_v_ones), Py_NE)); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_13 = __pyx_t_12;
        } else {
          __pyx_t_13 = __pyx_t_6;
        }
        if (__pyx_t_13) {
 844:                         equals = False
          /* "water_algorithm_cython.pyx":844
 *                 for i in xrange(N):
 *                     if nbbv[i] == 1 and self.nearest_neighbors_nos[0, molecule_no, i] not in ones:
 *                         equals = False             # <<<<<<<<<<<<<<
 *                         break
 *                 if equals:
 */
          __pyx_v_equals = 0;
 845:                         break
          /* "water_algorithm_cython.pyx":845
 *                     if nbbv[i] == 1 and self.nearest_neighbors_nos[0, molecule_no, i] not in ones:
 *                         equals = False
 *                         break             # <<<<<<<<<<<<<<
 *                 if equals:
 *                     return True
 */
          goto __pyx_L10_break;
          goto __pyx_L11;
        }
        __pyx_L11:;
      }
      __pyx_L10_break:;
 846:                 if equals:
      /* "water_algorithm_cython.pyx":846
 *                         equals = False
 *                         break
 *                 if equals:             # <<<<<<<<<<<<<<
 *                     return True
 * 
 */
      if (__pyx_v_equals) {
 847:                     return True
        /* "water_algorithm_cython.pyx":847
 *                         break
 *                 if equals:
 *                     return True             # <<<<<<<<<<<<<<
 * 
 *                 wo += 1
 */
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_r = __pyx_t_2;
        __pyx_t_2 = 0;
        goto __pyx_L0;
        goto __pyx_L12;
      }
      __pyx_L12:;
 848: 
 849:                 wo += 1
      /* "water_algorithm_cython.pyx":849
 *                     return True
 * 
 *                 wo += 1             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_v_wo = (__pyx_v_wo + 1);
    }
    goto __pyx_L3;
  }
  __pyx_L3:;
 850:         return False
  /* "water_algorithm_cython.pyx":850
 * 
 *                 wo += 1
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     cpdef bint additional_requirements_met(self, signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.wo_is_equal_with_any_of_previous_wos", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_nbbv, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
  __Pyx_XDECREF(__pyx_v_ones);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 851: 
 852:     cpdef bint additional_requirements_met(self, signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no):
/* "water_algorithm_cython.pyx":852
 *         return False
 * 
 *     cpdef bint additional_requirements_met(self, signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_51additional_requirements_met(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_22water_algorithm_cython_14WaterAlgorithm_additional_requirements_met(CYTHON_UNUSED struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, CYTHON_UNUSED signed char __pyx_v_water_orientation, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_water_orient, CYTHON_UNUSED unsigned char __pyx_v_molecule_no, int __pyx_skip_dispatch) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("additional_requirements_met", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_87); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_51additional_requirements_met)) {
      __pyx_t_2 = PyInt_FromLong(__pyx_v_water_orientation); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(!__pyx_v_water_orient.memview)) { __Pyx_RaiseUnboundLocalError("water_orient"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_water_orient, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyInt_FromLong(__pyx_v_molecule_no); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_6;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

/* "water_algorithm_cython.pyx":852
 *         return False
 * 
 *     cpdef bint additional_requirements_met(self, signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_50additional_requirements_met(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, signed char __pyx_v_water_orientation, __Pyx_memviewslice __pyx_v_water_orient, unsigned char __pyx_v_molecule_no) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("additional_requirements_met", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_water_orient.memview)) { __Pyx_RaiseUnboundLocalError("water_orient"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = __Pyx_PyBool_FromLong(((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->additional_requirements_met(__pyx_v_self, __pyx_v_water_orientation, __pyx_v_water_orient, __pyx_v_molecule_no, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.additional_requirements_met", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orient, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 853:         return True
  /* "water_algorithm_cython.pyx":853
 * 
 *     cpdef bint additional_requirements_met(self, signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no):
 *         return True             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("water_algorithm_cython.WaterAlgorithm.additional_requirements_met", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_51additional_requirements_met(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_51additional_requirements_met(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  signed char __pyx_v_water_orientation;
  __Pyx_memviewslice __pyx_v_water_orient = { 0, 0, { 0 }, { 0 }, { 0 } };
  unsigned char __pyx_v_molecule_no;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("additional_requirements_met (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_orientation,&__pyx_n_s__water_orient,&__pyx_n_s__molecule_no,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orient)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("additional_requirements_met", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__molecule_no)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("additional_requirements_met", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "additional_requirements_met") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_water_orientation = __Pyx_PyInt_AsSignedChar(values[0]); if (unlikely((__pyx_v_water_orientation == (signed char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_water_orient = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(values[1]); if (unlikely(!__pyx_v_water_orient.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_molecule_no = __Pyx_PyInt_AsUnsignedChar(values[2]); if (unlikely((__pyx_v_molecule_no == (unsigned char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("additional_requirements_met", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.additional_requirements_met", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_50additional_requirements_met(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_water_orientation, __pyx_v_water_orient, __pyx_v_molecule_no);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 854: 
 855: 
 856:     cdef bool water_orientation_is_valid(self, signed char water_orientation, np.ndarray[DTYPE2_t, ndim=1] water_orient, unsigned char molecule_no):
/* "water_algorithm_cython.pyx":856
 * 
 * 
 *     cdef bool water_orientation_is_valid(self, signed char water_orientation, np.ndarray[DTYPE2_t, ndim=1] water_orient, unsigned char molecule_no):             # <<<<<<<<<<<<<<
 *         """
 *              go through all neighbors and check that there are no breakage of ice rules
 */

static PyBoolObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_water_orientation_is_valid(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, signed char __pyx_v_water_orientation, PyArrayObject *__pyx_v_water_orient, unsigned char __pyx_v_molecule_no) {
  PyArrayObject *__pyx_v_nn = 0;
  PyArrayObject *__pyx_v_nearest_neighbors_nos = 0;
  PyArrayObject *__pyx_v_nps = 0;
  __Pyx_memviewslice __pyx_v_bvv = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_nbbv = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_periodic;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_periodicity_axis;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_nearest_neighbor_no;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_opposite;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_n;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_neighbor_bv_value;
  PyBoolObject *__pyx_v_neighbor_set = 0;
  int __pyx_v_l;
  int __pyx_v_x;
  int __pyx_v_N;
  int __pyx_v_M;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nearest_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_nearest_neighbors_nos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nn;
  __Pyx_Buffer __pyx_pybuffer_nn;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nps;
  __Pyx_Buffer __pyx_pybuffer_nps;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orient;
  __Pyx_Buffer __pyx_pybuffer_water_orient;
  PyBoolObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("water_orientation_is_valid", 0);
  __pyx_pybuffer_nn.pybuffer.buf = NULL;
  __pyx_pybuffer_nn.refcount = 0;
  __pyx_pybuffernd_nn.data = NULL;
  __pyx_pybuffernd_nn.rcbuffer = &__pyx_pybuffer_nn;
  __pyx_pybuffer_nearest_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_nearest_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_nearest_neighbors_nos.data = NULL;
  __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer = &__pyx_pybuffer_nearest_neighbors_nos;
  __pyx_pybuffer_nps.pybuffer.buf = NULL;
  __pyx_pybuffer_nps.refcount = 0;
  __pyx_pybuffernd_nps.data = NULL;
  __pyx_pybuffernd_nps.rcbuffer = &__pyx_pybuffer_nps;
  __pyx_pybuffer_water_orient.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orient.refcount = 0;
  __pyx_pybuffernd_water_orient.data = NULL;
  __pyx_pybuffernd_water_orient.rcbuffer = &__pyx_pybuffer_water_orient;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orient, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orient.diminfo[0].strides = __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orient.diminfo[0].shape = __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.shape[0];
 857:         """
 858:              go through all neighbors and check that there are no breakage of ice rules
 859:                 if there is: return False
 860:                 else return True
 861: 
 862:             not used by the actual process but used by calculate_possible_combinations -method. So it can not be deleted!
 863:         """
 864:         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
  /* "water_algorithm_cython.pyx":864
 *             not used by the actual process but used by calculate_possible_combinations -method. So it can not be deleted!
 *         """
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         cdef np.ndarray[DTYPE_t, ndim=1] nps = self.nearest_neighbors_nos[1][molecule_no]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_nn = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_3 = 0;
  __pyx_v_nn = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 865:         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = self.nearest_neighbors_nos
  /* "water_algorithm_cython.pyx":865
 *         """
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = self.nearest_neighbors_nos             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE_t, ndim=1] nps = self.nearest_neighbors_nos[1][molecule_no]
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_nearest_neighbors_nos = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_4 = 0;
  __pyx_v_nearest_neighbors_nos = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 866:         cdef np.ndarray[DTYPE_t, ndim=1] nps = self.nearest_neighbors_nos[1][molecule_no]
  /* "water_algorithm_cython.pyx":866
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0][molecule_no]
 *         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         cdef np.ndarray[DTYPE_t, ndim=1] nps = self.nearest_neighbors_nos[1][molecule_no]             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef DTYPE2_t[::1] nbbv
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nps.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_nps = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nps.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nps.diminfo[0].strides = __pyx_pybuffernd_nps.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nps.diminfo[0].shape = __pyx_pybuffernd_nps.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_nps = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 867:         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
  /* "water_algorithm_cython.pyx":867
 *         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         cdef np.ndarray[DTYPE_t, ndim=1] nps = self.nearest_neighbors_nos[1][molecule_no]
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] nbbv
 *         #assert not self.periodic or len(nn)==4
 */
  __pyx_t_6 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_water_orientation); if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_bvv = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
 868:         cdef DTYPE2_t[::1] nbbv
 869:         #assert not self.periodic or len(nn)==4
 870:         cdef DTYPE_t periodic, periodicity_axis,  nearest_neighbor_no, opposite, n
 871:         cdef DTYPE2_t neighbor_bv_value
 872:         cdef bool neighbor_set
 873:         cdef int l, x, N = nn.shape[0], M
  /* "water_algorithm_cython.pyx":873
 *         cdef DTYPE2_t neighbor_bv_value
 *         cdef bool neighbor_set
 *         cdef int l, x, N = nn.shape[0], M             # <<<<<<<<<<<<<<
 *         for l from 0 <= l < N:
 *             nearest_neighbor_no = nn[l]
 */
  __pyx_v_N = (__pyx_v_nn->dimensions[0]);
 874:         for l from 0 <= l < N:
  /* "water_algorithm_cython.pyx":874
 *         cdef bool neighbor_set
 *         cdef int l, x, N = nn.shape[0], M
 *         for l from 0 <= l < N:             # <<<<<<<<<<<<<<
 *             nearest_neighbor_no = nn[l]
 *             periodic = nps[l]
 */
  __pyx_t_7 = __pyx_v_N;
  for (__pyx_v_l = 0; __pyx_v_l < __pyx_t_7; __pyx_v_l++) {
 875:             nearest_neighbor_no = nn[l]
    /* "water_algorithm_cython.pyx":875
 *         cdef int l, x, N = nn.shape[0], M
 *         for l from 0 <= l < N:
 *             nearest_neighbor_no = nn[l]             # <<<<<<<<<<<<<<
 *             periodic = nps[l]
 *             periodicity_axis = self.nearest_neighbors_nos[2][molecule_no][l]
 */
    __pyx_t_8 = __pyx_v_l;
    __pyx_v_nearest_neighbor_no = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_nn.diminfo[0].strides));
 876:             periodic = nps[l]
    /* "water_algorithm_cython.pyx":876
 *         for l from 0 <= l < N:
 *             nearest_neighbor_no = nn[l]
 *             periodic = nps[l]             # <<<<<<<<<<<<<<
 *             periodicity_axis = self.nearest_neighbors_nos[2][molecule_no][l]
 *             neighbor_set = True
 */
    __pyx_t_9 = __pyx_v_l;
    __pyx_v_periodic = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nps.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_nps.diminfo[0].strides));
 877:             periodicity_axis = self.nearest_neighbors_nos[2][molecule_no][l]
    /* "water_algorithm_cython.pyx":877
 *             nearest_neighbor_no = nn[l]
 *             periodic = nps[l]
 *             periodicity_axis = self.nearest_neighbors_nos[2][molecule_no][l]             # <<<<<<<<<<<<<<
 *             neighbor_set = True
 *             neighbor_bv_value = 0
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_molecule_no, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_l, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyInt_from_py_npy_uint8(__pyx_t_2); if (unlikely((__pyx_t_10 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_periodicity_axis = __pyx_t_10;
 878:             neighbor_set = True
    /* "water_algorithm_cython.pyx":878
 *             periodic = nps[l]
 *             periodicity_axis = self.nearest_neighbors_nos[2][molecule_no][l]
 *             neighbor_set = True             # <<<<<<<<<<<<<<
 *             neighbor_bv_value = 0
 *             opposite = get_opposite_periodicity_axis_number(periodicity_axis)
 */
    __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_neighbor_set));
    __pyx_v_neighbor_set = ((PyBoolObject *)__pyx_t_2);
    __pyx_t_2 = 0;
 879:             neighbor_bv_value = 0
    /* "water_algorithm_cython.pyx":879
 *             periodicity_axis = self.nearest_neighbors_nos[2][molecule_no][l]
 *             neighbor_set = True
 *             neighbor_bv_value = 0             # <<<<<<<<<<<<<<
 *             opposite = get_opposite_periodicity_axis_number(periodicity_axis)
 *             # get corresponding water_orientation_value of neighbor and store it to neighbor_bv_value
 */
    __pyx_v_neighbor_bv_value = 0;
 880:             opposite = get_opposite_periodicity_axis_number(periodicity_axis)
    /* "water_algorithm_cython.pyx":880
 *             neighbor_set = True
 *             neighbor_bv_value = 0
 *             opposite = get_opposite_periodicity_axis_number(periodicity_axis)             # <<<<<<<<<<<<<<
 *             # get corresponding water_orientation_value of neighbor and store it to neighbor_bv_value
 *             #   -first check that the neighbor has a value
 */
    __pyx_v_opposite = __pyx_f_22water_algorithm_cython_get_opposite_periodicity_axis_number(__pyx_v_periodicity_axis);
 881:             # get corresponding water_orientation_value of neighbor and store it to neighbor_bv_value
 882:             #   -first check that the neighbor has a value
 883:             #      - if not then no breakage happens
 884:             if water_orient[nearest_neighbor_no] != -1:
    /* "water_algorithm_cython.pyx":884
 *             #   -first check that the neighbor has a value
 *             #      - if not then no breakage happens
 *             if water_orient[nearest_neighbor_no] != -1:             # <<<<<<<<<<<<<<
 *                 # current neighbors bond variable values
 *                 nbbv = get_bond_variable_values_from_water_orientation(water_orient[nearest_neighbor_no])
 */
    __pyx_t_10 = __pyx_v_nearest_neighbor_no;
    __pyx_t_11 = ((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_water_orient.diminfo[0].strides)) != -1);
    if (__pyx_t_11) {
 885:                 # current neighbors bond variable values
 886:                 nbbv = get_bond_variable_values_from_water_orientation(water_orient[nearest_neighbor_no])
      /* "water_algorithm_cython.pyx":886
 *             if water_orient[nearest_neighbor_no] != -1:
 *                 # current neighbors bond variable values
 *                 nbbv = get_bond_variable_values_from_water_orientation(water_orient[nearest_neighbor_no])             # <<<<<<<<<<<<<<
 *                 M = nearest_neighbors_nos[0, nearest_neighbor_no].shape[0]
 *                 for x from 0 <= x < M:
 */
      __pyx_t_12 = __pyx_v_nearest_neighbor_no;
      __pyx_t_6 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation((*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_water_orient.diminfo[0].strides))); if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __PYX_XDEC_MEMVIEW(&__pyx_v_nbbv, 1);
      __pyx_v_nbbv = __pyx_t_6;
      __pyx_t_6.memview = NULL;
      __pyx_t_6.data = NULL;
 887:                 M = nearest_neighbors_nos[0, nearest_neighbor_no].shape[0]
      /* "water_algorithm_cython.pyx":887
 *                 # current neighbors bond variable values
 *                 nbbv = get_bond_variable_values_from_water_orientation(water_orient[nearest_neighbor_no])
 *                 M = nearest_neighbors_nos[0, nearest_neighbor_no].shape[0]             # <<<<<<<<<<<<<<
 *                 for x from 0 <= x < M:
 *                     n = nearest_neighbors_nos[0, nearest_neighbor_no, x]
 */
      __pyx_t_2 = __Pyx_PyInt_to_py_npy_uint8(__pyx_v_nearest_neighbor_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_nearest_neighbors_nos), ((PyObject *)__pyx_t_1)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_M = __pyx_t_13;
 888:                 for x from 0 <= x < M:
      /* "water_algorithm_cython.pyx":888
 *                 nbbv = get_bond_variable_values_from_water_orientation(water_orient[nearest_neighbor_no])
 *                 M = nearest_neighbors_nos[0, nearest_neighbor_no].shape[0]
 *                 for x from 0 <= x < M:             # <<<<<<<<<<<<<<
 *                     n = nearest_neighbors_nos[0, nearest_neighbor_no, x]
 *                     # find the neighbor that corresponds to the molecule currently handled (i) [and has the same periodicity and the periodicity axis correspond]
 */
      __pyx_t_13 = __pyx_v_M;
      for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_13; __pyx_v_x++) {
 889:                     n = nearest_neighbors_nos[0, nearest_neighbor_no, x]
        /* "water_algorithm_cython.pyx":889
 *                 M = nearest_neighbors_nos[0, nearest_neighbor_no].shape[0]
 *                 for x from 0 <= x < M:
 *                     n = nearest_neighbors_nos[0, nearest_neighbor_no, x]             # <<<<<<<<<<<<<<
 *                     # find the neighbor that corresponds to the molecule currently handled (i) [and has the same periodicity and the periodicity axis correspond]
 *                     if n == molecule_no and nearest_neighbors_nos[1, nearest_neighbor_no, x] == periodic and nearest_neighbors_nos[2, nearest_neighbor_no, x] == opposite:
 */
        __pyx_t_14 = 0;
        __pyx_t_15 = __pyx_v_nearest_neighbor_no;
        __pyx_t_16 = __pyx_v_x;
        __pyx_v_n = (*__Pyx_BufPtrStrided3d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides, __pyx_t_16, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides));
 890:                     # find the neighbor that corresponds to the molecule currently handled (i) [and has the same periodicity and the periodicity axis correspond]
 891:                     if n == molecule_no and nearest_neighbors_nos[1, nearest_neighbor_no, x] == periodic and nearest_neighbors_nos[2, nearest_neighbor_no, x] == opposite:
        /* "water_algorithm_cython.pyx":891
 *                     n = nearest_neighbors_nos[0, nearest_neighbor_no, x]
 *                     # find the neighbor that corresponds to the molecule currently handled (i) [and has the same periodicity and the periodicity axis correspond]
 *                     if n == molecule_no and nearest_neighbors_nos[1, nearest_neighbor_no, x] == periodic and nearest_neighbors_nos[2, nearest_neighbor_no, x] == opposite:             # <<<<<<<<<<<<<<
 *                         neighbor_bv_value = nbbv[x]
 *                         break
 */
        __pyx_t_11 = (__pyx_v_n == __pyx_v_molecule_no);
        if (__pyx_t_11) {
          __pyx_t_17 = 1;
          __pyx_t_18 = __pyx_v_nearest_neighbor_no;
          __pyx_t_19 = __pyx_v_x;
          __pyx_t_20 = ((*__Pyx_BufPtrStrided3d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides, __pyx_t_18, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides, __pyx_t_19, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides)) == __pyx_v_periodic);
          if (__pyx_t_20) {
            __pyx_t_21 = 2;
            __pyx_t_22 = __pyx_v_nearest_neighbor_no;
            __pyx_t_23 = __pyx_v_x;
            __pyx_t_24 = ((*__Pyx_BufPtrStrided3d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides, __pyx_t_23, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides)) == __pyx_v_opposite);
            __pyx_t_25 = __pyx_t_24;
          } else {
            __pyx_t_25 = __pyx_t_20;
          }
          __pyx_t_20 = __pyx_t_25;
        } else {
          __pyx_t_20 = __pyx_t_11;
        }
        if (__pyx_t_20) {
 892:                         neighbor_bv_value = nbbv[x]
          /* "water_algorithm_cython.pyx":892
 *                     # find the neighbor that corresponds to the molecule currently handled (i) [and has the same periodicity and the periodicity axis correspond]
 *                     if n == molecule_no and nearest_neighbors_nos[1, nearest_neighbor_no, x] == periodic and nearest_neighbors_nos[2, nearest_neighbor_no, x] == opposite:
 *                         neighbor_bv_value = nbbv[x]             # <<<<<<<<<<<<<<
 *                         break
 *             else:
 */
          __pyx_t_26 = __pyx_v_x;
          __pyx_v_neighbor_bv_value = (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_nbbv.data) + __pyx_t_26)) )));
 893:                         break
          /* "water_algorithm_cython.pyx":893
 *                     if n == molecule_no and nearest_neighbors_nos[1, nearest_neighbor_no, x] == periodic and nearest_neighbors_nos[2, nearest_neighbor_no, x] == opposite:
 *                         neighbor_bv_value = nbbv[x]
 *                         break             # <<<<<<<<<<<<<<
 *             else:
 *                 neighbor_set = False
 */
          goto __pyx_L7_break;
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
      __pyx_L7_break:;
      goto __pyx_L5;
    }
    /*else*/ {
 894:             else:
 895:                 neighbor_set = False
      /* "water_algorithm_cython.pyx":895
 *                         break
 *             else:
 *                 neighbor_set = False             # <<<<<<<<<<<<<<
 *             if water_orientation > 9 and nearest_neighbor_no == molecule_no and bvv[l] != -1:
 *                 return False
 */
      __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_neighbor_set));
      __pyx_v_neighbor_set = ((PyBoolObject *)__pyx_t_2);
      __pyx_t_2 = 0;
    }
    __pyx_L5:;
 896:             if water_orientation > 9 and nearest_neighbor_no == molecule_no and bvv[l] != -1:
    /* "water_algorithm_cython.pyx":896
 *             else:
 *                 neighbor_set = False
 *             if water_orientation > 9 and nearest_neighbor_no == molecule_no and bvv[l] != -1:             # <<<<<<<<<<<<<<
 *                 return False
 *              # if both bond variables have the same value, then we have not succeeded
 */
    __pyx_t_20 = (__pyx_v_water_orientation > 9);
    if (__pyx_t_20) {
      __pyx_t_11 = (__pyx_v_nearest_neighbor_no == __pyx_v_molecule_no);
      if (__pyx_t_11) {
        __pyx_t_13 = __pyx_v_l;
        __pyx_t_25 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_13)) ))) != -1);
        __pyx_t_24 = __pyx_t_25;
      } else {
        __pyx_t_24 = __pyx_t_11;
      }
      __pyx_t_11 = __pyx_t_24;
    } else {
      __pyx_t_11 = __pyx_t_20;
    }
    if (__pyx_t_11) {
 897:                 return False
      /* "water_algorithm_cython.pyx":897
 *                 neighbor_set = False
 *             if water_orientation > 9 and nearest_neighbor_no == molecule_no and bvv[l] != -1:
 *                 return False             # <<<<<<<<<<<<<<
 *              # if both bond variables have the same value, then we have not succeeded
 *             if neighbor_set and bvv[l] == neighbor_bv_value:
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyBoolObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;
      goto __pyx_L9;
    }
    __pyx_L9:;
 898:              # if both bond variables have the same value, then we have not succeeded
 899:             if neighbor_set and bvv[l] == neighbor_bv_value:
    /* "water_algorithm_cython.pyx":899
 *                 return False
 *              # if both bond variables have the same value, then we have not succeeded
 *             if neighbor_set and bvv[l] == neighbor_bv_value:             # <<<<<<<<<<<<<<
 *                 return False
 *         return True
 */
    __pyx_t_11 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_neighbor_set)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_11) {
      __pyx_t_27 = __pyx_v_l;
      __pyx_t_20 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_27)) ))) == __pyx_v_neighbor_bv_value);
      __pyx_t_24 = __pyx_t_20;
    } else {
      __pyx_t_24 = __pyx_t_11;
    }
    if (__pyx_t_24) {
 900:                 return False
      /* "water_algorithm_cython.pyx":900
 *              # if both bond variables have the same value, then we have not succeeded
 *             if neighbor_set and bvv[l] == neighbor_bv_value:
 *                 return False             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyBoolObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L0;
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
 901:         return True
  /* "water_algorithm_cython.pyx":901
 *             if neighbor_set and bvv[l] == neighbor_bv_value:
 *                 return False
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef inline int water_orientation_is_valid_using_possible_combinations(self, signed char water_orientation, np.ndarray[DTYPE2_t, ndim=1] water_orient, unsigned char molecule_no):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyBoolObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyBoolObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nps.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.water_orientation_is_valid", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nps.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __Pyx_XDECREF((PyObject *)__pyx_v_nearest_neighbors_nos);
  __Pyx_XDECREF((PyObject *)__pyx_v_nps);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_nbbv, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_neighbor_set);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 902: 
 903:     cdef inline int water_orientation_is_valid_using_possible_combinations(self, signed char water_orientation, np.ndarray[DTYPE2_t, ndim=1] water_orient, unsigned char molecule_no):
/* "water_algorithm_cython.pyx":903
 *         return True
 * 
 *     cdef inline int water_orientation_is_valid_using_possible_combinations(self, signed char water_orientation, np.ndarray[DTYPE2_t, ndim=1] water_orient, unsigned char molecule_no):             # <<<<<<<<<<<<<<
 *         """
 *             Checks if the given water orientation for molecule with number molecule_no
 */

static CYTHON_INLINE int __pyx_f_22water_algorithm_cython_14WaterAlgorithm_water_orientation_is_valid_using_possible_combinations(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, signed char __pyx_v_water_orientation, PyArrayObject *__pyx_v_water_orient, unsigned char __pyx_v_molecule_no) {
  PyArrayObject *__pyx_v_nn = 0;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_neighbor_no;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_i;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_combination_possible;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_N;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_neighbor_orientation;
  PyArrayObject *__pyx_v_possible_combinations = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nn;
  __Pyx_Buffer __pyx_pybuffer_nn;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_possible_combinations;
  __Pyx_Buffer __pyx_pybuffer_possible_combinations;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orient;
  __Pyx_Buffer __pyx_pybuffer_water_orient;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("water_orientation_is_valid_using_possible_combinations", 0);
  __pyx_pybuffer_nn.pybuffer.buf = NULL;
  __pyx_pybuffer_nn.refcount = 0;
  __pyx_pybuffernd_nn.data = NULL;
  __pyx_pybuffernd_nn.rcbuffer = &__pyx_pybuffer_nn;
  __pyx_pybuffer_possible_combinations.pybuffer.buf = NULL;
  __pyx_pybuffer_possible_combinations.refcount = 0;
  __pyx_pybuffernd_possible_combinations.data = NULL;
  __pyx_pybuffernd_possible_combinations.rcbuffer = &__pyx_pybuffer_possible_combinations;
  __pyx_pybuffer_water_orient.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orient.refcount = 0;
  __pyx_pybuffernd_water_orient.data = NULL;
  __pyx_pybuffernd_water_orient.rcbuffer = &__pyx_pybuffer_water_orient;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orient, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orient.diminfo[0].strides = __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orient.diminfo[0].shape = __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.shape[0];
 904:         """
 905:             Checks if the given water orientation for molecule with number molecule_no
 906:              is valid in environment of orientations given in water_orient
 907:             DEPRECATED! The 'static' method is used.
 908:         """
 909:         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0, molecule_no]
  /* "water_algorithm_cython.pyx":909
 *             DEPRECATED! The 'static' method is used.
 *         """
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0, molecule_no]             # <<<<<<<<<<<<<<
 *         cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]
 *         cdef DTYPE2_t neighbor_orientation
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_molecule_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, ((PyObject *)__pyx_t_3)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_nn = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_4 = 0;
  __pyx_v_nn = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 910:         cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]
  /* "water_algorithm_cython.pyx":910
 *         """
 *         cdef np.ndarray[DTYPE_t, ndim=1] nn = self.nearest_neighbors_nos[0, molecule_no]
 *         cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t neighbor_orientation
 *         cdef np.ndarray[DTYPE_t, ndim=3] possible_combinations = self.possible_combinations
 */
  __pyx_v_N = (__pyx_v_nn->dimensions[0]);
 911:         cdef DTYPE2_t neighbor_orientation
 912:         cdef np.ndarray[DTYPE_t, ndim=3] possible_combinations = self.possible_combinations
  /* "water_algorithm_cython.pyx":912
 *         cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]
 *         cdef DTYPE2_t neighbor_orientation
 *         cdef np.ndarray[DTYPE_t, ndim=3] possible_combinations = self.possible_combinations             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]
 */
  if (unlikely(!__pyx_v_self->possible_combinations.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");{__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}}
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_self->possible_combinations, 3, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_possible_combinations = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_possible_combinations.diminfo[0].strides = __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_possible_combinations.diminfo[0].shape = __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_possible_combinations.diminfo[1].strides = __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_possible_combinations.diminfo[1].shape = __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_possible_combinations.diminfo[2].strides = __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_possible_combinations.diminfo[2].shape = __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_possible_combinations = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 913:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":913
 *         cdef DTYPE2_t neighbor_orientation
 *         cdef np.ndarray[DTYPE_t, ndim=3] possible_combinations = self.possible_combinations
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             neighbor_no = nn[i]
 *             neighbor_orientation = water_orient[neighbor_no]
 */
  __pyx_t_6 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
 914:             neighbor_no = nn[i]
    /* "water_algorithm_cython.pyx":914
 *         cdef np.ndarray[DTYPE_t, ndim=3] possible_combinations = self.possible_combinations
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]             # <<<<<<<<<<<<<<
 *             neighbor_orientation = water_orient[neighbor_no]
 *             if neighbor_orientation == -1:
 */
    __pyx_t_7 = __pyx_v_i;
    __pyx_v_neighbor_no = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nn.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_nn.diminfo[0].strides));
 915:             neighbor_orientation = water_orient[neighbor_no]
    /* "water_algorithm_cython.pyx":915
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]
 *             neighbor_orientation = water_orient[neighbor_no]             # <<<<<<<<<<<<<<
 *             if neighbor_orientation == -1:
 *                 continue
 */
    __pyx_t_8 = __pyx_v_neighbor_no;
    __pyx_v_neighbor_orientation = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_water_orient.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_water_orient.diminfo[0].strides));
 916:             if neighbor_orientation == -1:
    /* "water_algorithm_cython.pyx":916
 *             neighbor_no = nn[i]
 *             neighbor_orientation = water_orient[neighbor_no]
 *             if neighbor_orientation == -1:             # <<<<<<<<<<<<<<
 *                 continue
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 */
    __pyx_t_9 = (__pyx_v_neighbor_orientation == -1);
    if (__pyx_t_9) {
 917:                 continue
      /* "water_algorithm_cython.pyx":917
 *             neighbor_orientation = water_orient[neighbor_no]
 *             if neighbor_orientation == -1:
 *                 continue             # <<<<<<<<<<<<<<
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *             if combination_possible == 0:
 */
      goto __pyx_L3_continue;
      goto __pyx_L5;
    }
    __pyx_L5:;
 918:             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
    /* "water_algorithm_cython.pyx":918
 *             if neighbor_orientation == -1:
 *                 continue
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]             # <<<<<<<<<<<<<<
 *             if combination_possible == 0:
 *                 return 0
 */
    __pyx_t_10 = __pyx_v_i;
    __pyx_t_11 = __pyx_v_water_orientation;
    __pyx_t_12 = __pyx_v_neighbor_orientation;
    __pyx_v_combination_possible = (*__Pyx_BufPtrStrided3d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_possible_combinations.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_possible_combinations.diminfo[1].strides, __pyx_t_12, __pyx_pybuffernd_possible_combinations.diminfo[2].strides));
 919:             if combination_possible == 0:
    /* "water_algorithm_cython.pyx":919
 *                 continue
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *             if combination_possible == 0:             # <<<<<<<<<<<<<<
 *                 return 0
 *         return 1
 */
    __pyx_t_9 = (__pyx_v_combination_possible == 0);
    if (__pyx_t_9) {
 920:                 return 0
      /* "water_algorithm_cython.pyx":920
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *             if combination_possible == 0:
 *                 return 0             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    __pyx_L3_continue:;
  }
 921:         return 1
  /* "water_algorithm_cython.pyx":921
 *             if combination_possible == 0:
 *                 return 0
 *         return 1             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] handle_molecule_algorithm_2(self, unsigned char i, DTYPE2_t[:, ::1] water_orientations, DTYPE_t [:, :, ::1] possible_combinations, DTYPE_t [::1] nn, bint init, int *discarded):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("water_algorithm_cython.WaterAlgorithm.water_orientation_is_valid_using_possible_combinations", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_possible_combinations.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orient.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __Pyx_XDECREF((PyObject *)__pyx_v_possible_combinations);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 922: 
 923:     cdef np.ndarray[DTYPE2_t, ndim=2] handle_molecule_algorithm_2(self, unsigned char i, DTYPE2_t[:, ::1] water_orientations, DTYPE_t [:, :, ::1] possible_combinations, DTYPE_t [::1] nn, bint init, int *discarded):
/* "water_algorithm_cython.pyx":923
 *         return 1
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] handle_molecule_algorithm_2(self, unsigned char i, DTYPE2_t[:, ::1] water_orientations, DTYPE_t [:, :, ::1] possible_combinations, DTYPE_t [::1] nn, bint init, int *discarded):             # <<<<<<<<<<<<<<
 *         """
 *             Handles the 'ice rules' check part of the enumeration. Also initializes the water_orientations object if the input is None.
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_handle_molecule_algorithm_2(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, unsigned char __pyx_v_i, __Pyx_memviewslice __pyx_v_water_orientations, __Pyx_memviewslice __pyx_v_possible_combinations, __Pyx_memviewslice __pyx_v_nn, int __pyx_v_init, int *__pyx_v_discarded) {
  int __pyx_v_j;
  int __pyx_v_count;
  int __pyx_v_N;
  __Pyx_memviewslice __pyx_v_new_water_orientations = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation;
  __Pyx_memviewslice __pyx_v_water_orientations_trial = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_water_orient = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_molecule_algorithm_2", 0);
  __PYX_INC_MEMVIEW(&__pyx_v_water_orientations, 1);
 924:         """
 925:             Handles the 'ice rules' check part of the enumeration. Also initializes the water_orientations object if the input is None.
 926:             Parameters:
 927:                 i                    : number of molecule in the raft
 928:                 water_orientations   : the water orientations lists in two dimensional (numpy) array
 929:                 possible_combinations: the combinations that are possible for this molecule and the neighbors orientations, calculated by  'calculate_possible_combinations' -method
 930:         """
 931:         cdef int j, count = 0, N = water_orientations.shape[0]
  /* "water_algorithm_cython.pyx":931
 *                 possible_combinations: the combinations that are possible for this molecule and the neighbors orientations, calculated by  'calculate_possible_combinations' -method
 *         """
 *         cdef int j, count = 0, N = water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[:, ::1] new_water_orientations
 *         cdef DTYPE2_t water_orientation
 */
  __pyx_v_count = 0;
  __pyx_v_N = (__pyx_v_water_orientations.shape[0]);
 932:         cdef DTYPE2_t[:, ::1] new_water_orientations
 933:         cdef DTYPE2_t water_orientation
 934:         cdef DTYPE2_t[::1] water_orientations_trial
 935:         cdef DTYPE2_t[::1] water_orient
 936:         if init:
  /* "water_algorithm_cython.pyx":936
 *         cdef DTYPE2_t[::1] water_orientations_trial
 *         cdef DTYPE2_t[::1] water_orient
 *         if init:             # <<<<<<<<<<<<<<
 *             N = 1
 *             water_orientations = np.ndarray((1, self.N), dtype=DTYPE2)
 */
  if (__pyx_v_init) {
 937:             N = 1
    /* "water_algorithm_cython.pyx":937
 *         cdef DTYPE2_t[::1] water_orient
 *         if init:
 *             N = 1             # <<<<<<<<<<<<<<
 *             water_orientations = np.ndarray((1, self.N), dtype=DTYPE2)
 *             water_orientations[:] = -1
 */
    __pyx_v_N = 1;
 938:             water_orientations = np.ndarray((1, self.N), dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":938
 *         if init:
 *             N = 1
 *             water_orientations = np.ndarray((1, self.N), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *             water_orientations[:] = -1
 *             new_water_orientations = np.ndarray((6, self.N), dtype=DTYPE2)
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
    if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
    __pyx_v_water_orientations = __pyx_t_4;
    __pyx_t_4.memview = NULL;
    __pyx_t_4.data = NULL;
 939:             water_orientations[:] = -1
    /* "water_algorithm_cython.pyx":939
 *             N = 1
 *             water_orientations = np.ndarray((1, self.N), dtype=DTYPE2)
 *             water_orientations[:] = -1             # <<<<<<<<<<<<<<
 *             new_water_orientations = np.ndarray((6, self.N), dtype=DTYPE2)
 *         else:
 */
    __pyx_t_6 = -1;
    __pyx_t_5.data = __pyx_v_water_orientations.data;
    __pyx_t_5.memview = __pyx_v_water_orientations.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_5, 0);
    __pyx_t_5.shape[0] = __pyx_v_water_orientations.shape[0];
__pyx_t_5.strides[0] = __pyx_v_water_orientations.strides[0];
    __pyx_t_5.suboffsets[0] = -1;

__pyx_t_5.shape[1] = __pyx_v_water_orientations.shape[1];
__pyx_t_5.strides[1] = __pyx_v_water_orientations.strides[1];
    __pyx_t_5.suboffsets[1] = -1;

{
        __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_temp_scalar = -1;
        {
            Py_ssize_t __pyx_temp_extent = __pyx_t_5.shape[0] * __pyx_t_5.shape[1];
            Py_ssize_t __pyx_temp_idx;
            __pyx_t_22water_algorithm_cython_DTYPE2_t *__pyx_temp_pointer = (__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_t_5.data;
            for (__pyx_temp_idx = 0; __pyx_temp_idx < __pyx_temp_extent; __pyx_temp_idx++) {
              *((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_temp_pointer) = __pyx_temp_scalar;
              __pyx_temp_pointer += 1;
            }
        }
    }
    __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
 940:             new_water_orientations = np.ndarray((6, self.N), dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":940
 *             water_orientations = np.ndarray((1, self.N), dtype=DTYPE2)
 *             water_orientations[:] = -1
 *             new_water_orientations = np.ndarray((6, self.N), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         else:
 *             new_water_orientations = np.ndarray((6*N, self.N), dtype=DTYPE2)
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_int_6);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_6);
    __Pyx_GIVEREF(__pyx_int_6);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_1);
    if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_new_water_orientations = __pyx_t_7;
    __pyx_t_7.memview = NULL;
    __pyx_t_7.data = NULL;
    goto __pyx_L3;
  }
  /*else*/ {
 941:         else:
 942:             new_water_orientations = np.ndarray((6*N, self.N), dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":942
 *             new_water_orientations = np.ndarray((6, self.N), dtype=DTYPE2)
 *         else:
 *             new_water_orientations = np.ndarray((6*N, self.N), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         for j from 0 <= j < N:
 *             water_orient = water_orientations[j]
 */
    __pyx_t_1 = PyInt_FromLong((6 * __pyx_v_N)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_1 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_1);
    if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_new_water_orientations = __pyx_t_7;
    __pyx_t_7.memview = NULL;
    __pyx_t_7.data = NULL;
  }
  __pyx_L3:;
 943:         for j from 0 <= j < N:
  /* "water_algorithm_cython.pyx":943
 *         else:
 *             new_water_orientations = np.ndarray((6*N, self.N), dtype=DTYPE2)
 *         for j from 0 <= j < N:             # <<<<<<<<<<<<<<
 *             water_orient = water_orientations[j]
 *             if water_orient[i] != -1:
 */
  __pyx_t_6 = __pyx_v_N;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_6; __pyx_v_j++) {
 944:             water_orient = water_orientations[j]
    /* "water_algorithm_cython.pyx":944
 *             new_water_orientations = np.ndarray((6*N, self.N), dtype=DTYPE2)
 *         for j from 0 <= j < N:
 *             water_orient = water_orientations[j]             # <<<<<<<<<<<<<<
 *             if water_orient[i] != -1:
 *                 new_water_orientations[count] =  water_orient
 */
    __pyx_t_9 = -1;
    __pyx_t_8.data = __pyx_v_water_orientations.data;
    __pyx_t_8.memview = __pyx_v_water_orientations.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_8, 0);
    {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_j;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_water_orientations.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_water_orientations.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_8.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_8.shape[0] = __pyx_v_water_orientations.shape[1];
__pyx_t_8.strides[0] = __pyx_v_water_orientations.strides[1];
    __pyx_t_8.suboffsets[0] = -1;

__PYX_XDEC_MEMVIEW(&__pyx_v_water_orient, 1);
    __pyx_v_water_orient = __pyx_t_8;
    __pyx_t_8.memview = NULL;
    __pyx_t_8.data = NULL;
 945:             if water_orient[i] != -1:
    /* "water_algorithm_cython.pyx":945
 *         for j from 0 <= j < N:
 *             water_orient = water_orientations[j]
 *             if water_orient[i] != -1:             # <<<<<<<<<<<<<<
 *                 new_water_orientations[count] =  water_orient
 *                 count += 1
 */
    __pyx_t_10 = __pyx_v_i;
    __pyx_t_11 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_water_orient.data) + __pyx_t_10)) ))) != -1);
    if (__pyx_t_11) {
 946:                 new_water_orientations[count] =  water_orient
      /* "water_algorithm_cython.pyx":946
 *             water_orient = water_orientations[j]
 *             if water_orient[i] != -1:
 *                 new_water_orientations[count] =  water_orient             # <<<<<<<<<<<<<<
 *                 count += 1
 *             else:
 */
      __pyx_t_9 = -1;
      __pyx_t_12.data = __pyx_v_new_water_orientations.data;
      __pyx_t_12.memview = __pyx_v_new_water_orientations.memview;
      __PYX_INC_MEMVIEW(&__pyx_t_12, 0);
      {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_count;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_new_water_orientations.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_new_water_orientations.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_12.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_12.shape[0] = __pyx_v_new_water_orientations.shape[1];
__pyx_t_12.strides[0] = __pyx_v_new_water_orientations.strides[1];
    __pyx_t_12.suboffsets[0] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_v_water_orient, __pyx_t_12, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
 947:                 count += 1
      /* "water_algorithm_cython.pyx":947
 *             if water_orient[i] != -1:
 *                 new_water_orientations[count] =  water_orient
 *                 count += 1             # <<<<<<<<<<<<<<
 *             else:
 *                 for water_orientation from 0 <= water_orientation < 6:
 */
      __pyx_v_count = (__pyx_v_count + 1);
      goto __pyx_L6;
    }
    /*else*/ {
 948:             else:
 949:                 for water_orientation from 0 <= water_orientation < 6:
      /* "water_algorithm_cython.pyx":949
 *                 count += 1
 *             else:
 *                 for water_orientation from 0 <= water_orientation < 6:             # <<<<<<<<<<<<<<
 *                     #if  self.water_orientation_is_valid(water_orientation, water_orient, i) and self.additional_requirements_met(water_orientation, water_orient, i):
 * 
 */
      for (__pyx_v_water_orientation = 0; __pyx_v_water_orientation < 6; __pyx_v_water_orientation++) {
 950:                     #if  self.water_orientation_is_valid(water_orientation, water_orient, i) and self.additional_requirements_met(water_orientation, water_orient, i):
 951: 
 952:                     if  water_orientation_is_valid_using_possible_combinations(water_orientation, water_orient, i, possible_combinations, nn, init) == 1 and self.additional_requirements_met(water_orientation, water_orient, i):
        /* "water_algorithm_cython.pyx":952
 *                     #if  self.water_orientation_is_valid(water_orientation, water_orient, i) and self.additional_requirements_met(water_orientation, water_orient, i):
 * 
 *                     if  water_orientation_is_valid_using_possible_combinations(water_orientation, water_orient, i, possible_combinations, nn, init) == 1 and self.additional_requirements_met(water_orientation, water_orient, i):             # <<<<<<<<<<<<<<
 *                         water_orientations_trial = water_orient.copy()
 *                         water_orientations_trial[i] = water_orientation
 */
        __pyx_t_11 = (__pyx_f_22water_algorithm_cython_water_orientation_is_valid_using_possible_combinations(__pyx_v_water_orientation, __pyx_v_water_orient, __pyx_v_i, __pyx_v_possible_combinations, __pyx_v_nn, __pyx_v_init) == 1);
        if (__pyx_t_11) {
          __pyx_t_13 = ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->additional_requirements_met(__pyx_v_self, __pyx_v_water_orientation, __pyx_v_water_orient, __pyx_v_i, 0);
          __pyx_t_14 = __pyx_t_13;
        } else {
          __pyx_t_14 = __pyx_t_11;
        }
        if (__pyx_t_14) {
 953:                         water_orientations_trial = water_orient.copy()
          /* "water_algorithm_cython.pyx":953
 * 
 *                     if  water_orientation_is_valid_using_possible_combinations(water_orientation, water_orient, i, possible_combinations, nn, init) == 1 and self.additional_requirements_met(water_orientation, water_orient, i):
 *                         water_orientations_trial = water_orient.copy()             # <<<<<<<<<<<<<<
 *                         water_orientations_trial[i] = water_orientation
 *                         new_water_orientations[count] = water_orientations_trial
 */
          __pyx_t_15 = __pyx_memoryview_copy_slice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t_c(__pyx_v_water_orient); if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations_trial, 1);
          __pyx_v_water_orientations_trial = __pyx_t_15;
          __pyx_t_15.memview = NULL;
          __pyx_t_15.data = NULL;
 954:                         water_orientations_trial[i] = water_orientation
          /* "water_algorithm_cython.pyx":954
 *                     if  water_orientation_is_valid_using_possible_combinations(water_orientation, water_orient, i, possible_combinations, nn, init) == 1 and self.additional_requirements_met(water_orientation, water_orient, i):
 *                         water_orientations_trial = water_orient.copy()
 *                         water_orientations_trial[i] = water_orientation             # <<<<<<<<<<<<<<
 *                         new_water_orientations[count] = water_orientations_trial
 *                         count += 1
 */
          __pyx_t_16 = __pyx_v_i;
          *((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_water_orientations_trial.data) + __pyx_t_16)) )) = __pyx_v_water_orientation;
 955:                         new_water_orientations[count] = water_orientations_trial
          /* "water_algorithm_cython.pyx":955
 *                         water_orientations_trial = water_orient.copy()
 *                         water_orientations_trial[i] = water_orientation
 *                         new_water_orientations[count] = water_orientations_trial             # <<<<<<<<<<<<<<
 *                         count += 1
 *                     else:
 */
          __pyx_t_9 = -1;
          __pyx_t_17.data = __pyx_v_new_water_orientations.data;
          __pyx_t_17.memview = __pyx_v_new_water_orientations.memview;
          __PYX_INC_MEMVIEW(&__pyx_t_17, 0);
          {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_count;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_new_water_orientations.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_new_water_orientations.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_17.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_17.shape[0] = __pyx_v_new_water_orientations.shape[1];
__pyx_t_17.strides[0] = __pyx_v_new_water_orientations.strides[1];
    __pyx_t_17.suboffsets[0] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_v_water_orientations_trial, __pyx_t_17, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
 956:                         count += 1
          /* "water_algorithm_cython.pyx":956
 *                         water_orientations_trial[i] = water_orientation
 *                         new_water_orientations[count] = water_orientations_trial
 *                         count += 1             # <<<<<<<<<<<<<<
 *                     else:
 *                         discarded[0] += 1
 */
          __pyx_v_count = (__pyx_v_count + 1);
          goto __pyx_L9;
        }
        /*else*/ {
 957:                     else:
 958:                         discarded[0] += 1
          /* "water_algorithm_cython.pyx":958
 *                         count += 1
 *                     else:
 *                         discarded[0] += 1             # <<<<<<<<<<<<<<
 * 
 *                     #if success:# and not self.is_symmetric_with_another_result(water_orientations_trial, wo, [bond_variables_trial,  periodic_bond_variables_trial],  bv,   nearest_neighbors_nos):
 */
          __pyx_t_18 = 0;
          (__pyx_v_discarded[__pyx_t_18]) = ((__pyx_v_discarded[__pyx_t_18]) + 1);
        }
        __pyx_L9:;
      }
    }
    __pyx_L6:;
  }
 959: 
 960:                     #if success:# and not self.is_symmetric_with_another_result(water_orientations_trial, wo, [bond_variables_trial,  periodic_bond_variables_trial],  bv,   nearest_neighbors_nos):
 961:                     #new_results.append(result_trial)
 962:         return new_water_orientations.base[0:count]
  /* "water_algorithm_cython.pyx":962
 *                     #if success:# and not self.is_symmetric_with_another_result(water_orientations_trial, wo, [bond_variables_trial,  periodic_bond_variables_trial],  bv,   nearest_neighbors_nos):
 *                     #new_results.append(result_trial)
 *         return new_water_orientations.base[0:count]             # <<<<<<<<<<<<<<
 * 
 *     cdef ResultGroup single_wo_initial_grouping(self, DTYPE2_t[::1] water_orientation, DTYPE2_t[:, ::1] bond_variables):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_3, 0, __pyx_v_count, NULL, NULL, NULL, 1, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_molecule_algorithm_2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations_trial, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orient, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 963: 
 964:     cdef ResultGroup single_wo_initial_grouping(self, DTYPE2_t[::1] water_orientation, DTYPE2_t[:, ::1] bond_variables):
/* "water_algorithm_cython.pyx":964
 *         return new_water_orientations.base[0:count]
 * 
 *     cdef ResultGroup single_wo_initial_grouping(self, DTYPE2_t[::1] water_orientation, DTYPE2_t[:, ::1] bond_variables):             # <<<<<<<<<<<<<<
 *         """
 *             Groups a single water orientation list until the first level of result groups
 */

static struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_single_wo_initial_grouping(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_water_orientation, __Pyx_memviewslice __pyx_v_bond_variables) {
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_rg = 0;
  int __pyx_v_N;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("single_wo_initial_grouping", 0);
 965:         """
 966:             Groups a single water orientation list until the first level of result groups
 967:             Parameters:
 968:                 the water orientations of a single proton configuration
 969:             Returns the group in  which the water orientation belongs to
 970:         """
 971:         cdef ResultGroup rg
 972:         #cdef float s
 973: 
 974:         #s = time()
 975:         cdef int N = water_orientation.shape[0]
  /* "water_algorithm_cython.pyx":975
 * 
 *         #s = time()
 *         cdef int N = water_orientation.shape[0]             # <<<<<<<<<<<<<<
 *         get_bond_variables_3(water_orientation,  self.nearest_neighbors_nos, N, bond_variables)
 *         #self.conversion_time += time() - s
 */
  __pyx_v_N = (__pyx_v_water_orientation.shape[0]);
 976:         get_bond_variables_3(water_orientation,  self.nearest_neighbors_nos, N, bond_variables)
  /* "water_algorithm_cython.pyx":976
 *         #s = time()
 *         cdef int N = water_orientation.shape[0]
 *         get_bond_variables_3(water_orientation,  self.nearest_neighbors_nos, N, bond_variables)             # <<<<<<<<<<<<<<
 *         #self.conversion_time += time() - s
 *         rg = self.result_group._try_subgroups(bond_variables.base,  1)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_1);
  if (unlikely(!__pyx_t_2.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_v_water_orientation, __pyx_t_2, __pyx_v_N, __pyx_v_bond_variables);
  __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
 977:         #self.conversion_time += time() - s
 978:         rg = self.result_group._try_subgroups(bond_variables.base,  1)
  /* "water_algorithm_cython.pyx":978
 *         get_bond_variables_3(water_orientation,  self.nearest_neighbors_nos, N, bond_variables)
 *         #self.conversion_time += time() - s
 *         rg = self.result_group._try_subgroups(bond_variables.base,  1)             # <<<<<<<<<<<<<<
 * 
 *         #if self.store_bond_variables:
 */
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_bond_variables, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(__pyx_t_3);
  if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->_try_subgroups(__pyx_v_self->result_group, __pyx_t_4, 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __pyx_v_rg = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_3);
  __pyx_t_3 = 0;
 979: 
 980:         #if self.store_bond_variables:
 981:         #rg.add_result(water_orientation.base, bond_variables)
 982:         #else:
 983:         rg.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientation.base, None)
  /* "water_algorithm_cython.pyx":983
 *         #rg.add_result(water_orientation.base, bond_variables)
 *         #else:
 *         rg.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientation.base, None)             # <<<<<<<<<<<<<<
 *         return rg
 * 
 */
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_water_orientation, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(Py_None);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_rg->__pyx_vtab)->add_result(__pyx_v_rg, ((PyArrayObject *)__pyx_t_1), __pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
 984:         return rg
  /* "water_algorithm_cython.pyx":984
 *         #else:
 *         rg.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientation.base, None)
 *         return rg             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_rg));
  __pyx_r = __pyx_v_rg;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_19result_group_cython_ResultGroup *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_2, 1);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.single_wo_initial_grouping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_rg);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 985: 
 986: 
 987: 
 988:     cdef public tuple do_initial_grouping(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations, int depth_limit, bint scatter):
/* "water_algorithm_cython.pyx":988
 * 
 * 
 *     cdef public tuple do_initial_grouping(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations, int depth_limit, bint scatter):             # <<<<<<<<<<<<<<
 *         if scatter:
 *             water_orientations = comm.scatter(split_list(water_orientations, wanted_parts=size), root=0)
 */

PyObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_do_initial_grouping(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyArrayObject *__pyx_v_water_orientations, int __pyx_v_depth_limit, int __pyx_v_scatter) {
  int __pyx_v_wo_count;
  __Pyx_memviewslice __pyx_v_bond_variables = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_water_orientation = { 0, 0, { 0 }, { 0 }, { 0 } };
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_group = 0;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_rg = 0;
  PyObject *__pyx_v_groups = 0;
  PyObject *__pyx_v_new_groups = 0;
  int __pyx_v_i;
  CYTHON_UNUSED int __pyx_v_counter;
  int __pyx_v_depth;
  int __pyx_v_N;
  PyObject *__pyx_v_group_count = NULL;
  PyObject *__pyx_v_wo = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("do_initial_grouping", 0);
  __Pyx_INCREF((PyObject *)__pyx_v_water_orientations);
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
 989:         if scatter:
  /* "water_algorithm_cython.pyx":989
 * 
 *     cdef public tuple do_initial_grouping(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations, int depth_limit, bint scatter):
 *         if scatter:             # <<<<<<<<<<<<<<
 *             water_orientations = comm.scatter(split_list(water_orientations, wanted_parts=size), root=0)
 *         cdef int wo_count = water_orientations.shape[0]
 */
  if (__pyx_v_scatter) {
 990:             water_orientations = comm.scatter(split_list(water_orientations, wanted_parts=size), root=0)
    /* "water_algorithm_cython.pyx":990
 *     cdef public tuple do_initial_grouping(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations, int depth_limit, bint scatter):
 *         if scatter:
 *             water_orientations = comm.scatter(split_list(water_orientations, wanted_parts=size), root=0)             # <<<<<<<<<<<<<<
 *         cdef int wo_count = water_orientations.shape[0]
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_water_orientations));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_water_orientations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_water_orientations));
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_5 = PyInt_FromLong(size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__wanted_parts), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_water_orientations));
    __pyx_v_water_orientations = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 991:         cdef int wo_count = water_orientations.shape[0]
  /* "water_algorithm_cython.pyx":991
 *         if scatter:
 *             water_orientations = comm.scatter(split_list(water_orientations, wanted_parts=size), root=0)
 *         cdef int wo_count = water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         cdef DTYPE2_t[::1] water_orientation
 */
  __pyx_v_wo_count = (__pyx_v_water_orientations->dimensions[0]);
 992:         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":992
 *             water_orientations = comm.scatter(split_list(water_orientations, wanted_parts=size), root=0)
 *         cdef int wo_count = water_orientations.shape[0]
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] water_orientation
 *         cdef ResultGroup group, rg
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
  if (unlikely(!__pyx_t_11.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_bond_variables = __pyx_t_11;
  __pyx_t_11.memview = NULL;
  __pyx_t_11.data = NULL;
 993:         cdef DTYPE2_t[::1] water_orientation
 994:         cdef ResultGroup group, rg
 995:         cdef list groups, new_groups
 996:         # Get the result groups from 1st level
 997:         # NOTE: this can't be done to any other level
 998:         cdef int i, counter = 0
  /* "water_algorithm_cython.pyx":998
 *         # Get the result groups from 1st level
 *         # NOTE: this can't be done to any other level
 *         cdef int i, counter = 0             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < wo_count:
 *             water_orientation = water_orientations[i]
 */
  __pyx_v_counter = 0;
 999:         for i from 0 <= i < wo_count:
  /* "water_algorithm_cython.pyx":999
 *         # NOTE: this can't be done to any other level
 *         cdef int i, counter = 0
 *         for i from 0 <= i < wo_count:             # <<<<<<<<<<<<<<
 *             water_orientation = water_orientations[i]
 *             rg = self.single_wo_initial_grouping(water_orientation, bond_variables)
 */
  __pyx_t_7 = __pyx_v_wo_count;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 1000:             water_orientation = water_orientations[i]
    /* "water_algorithm_cython.pyx":1000
 *         cdef int i, counter = 0
 *         for i from 0 <= i < wo_count:
 *             water_orientation = water_orientations[i]             # <<<<<<<<<<<<<<
 *             rg = self.single_wo_initial_grouping(water_orientation, bond_variables)
 *         groups = self.result_group.get_subgroups_from_level(0)
 */
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_water_orientations), __pyx_v_i, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
    if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1000; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientation, 1);
    __pyx_v_water_orientation = __pyx_t_12;
    __pyx_t_12.memview = NULL;
    __pyx_t_12.data = NULL;
 1001:             rg = self.single_wo_initial_grouping(water_orientation, bond_variables)
    /* "water_algorithm_cython.pyx":1001
 *         for i from 0 <= i < wo_count:
 *             water_orientation = water_orientations[i]
 *             rg = self.single_wo_initial_grouping(water_orientation, bond_variables)             # <<<<<<<<<<<<<<
 *         groups = self.result_group.get_subgroups_from_level(0)
 *         cdef int depth = 1
 */
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->single_wo_initial_grouping(__pyx_v_self, __pyx_v_water_orientation, __pyx_v_bond_variables)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF(((PyObject *)__pyx_v_rg));
    __pyx_v_rg = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_4);
    __pyx_t_4 = 0;
  }
 1002:         groups = self.result_group.get_subgroups_from_level(0)
  /* "water_algorithm_cython.pyx":1002
 *             water_orientation = water_orientations[i]
 *             rg = self.single_wo_initial_grouping(water_orientation, bond_variables)
 *         groups = self.result_group.get_subgroups_from_level(0)             # <<<<<<<<<<<<<<
 *         cdef int depth = 1
 *         cdef int N = water_orientations.shape[1]
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->get_subgroups_from_level(__pyx_v_self->result_group, 0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_groups = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
 1003:         cdef int depth = 1
  /* "water_algorithm_cython.pyx":1003
 *             rg = self.single_wo_initial_grouping(water_orientation, bond_variables)
 *         groups = self.result_group.get_subgroups_from_level(0)
 *         cdef int depth = 1             # <<<<<<<<<<<<<<
 *         cdef int N = water_orientations.shape[1]
 *         #for f, group in enumerate(groups):
 */
  __pyx_v_depth = 1;
 1004:         cdef int N = water_orientations.shape[1]
  /* "water_algorithm_cython.pyx":1004
 *         groups = self.result_group.get_subgroups_from_level(0)
 *         cdef int depth = 1
 *         cdef int N = water_orientations.shape[1]             # <<<<<<<<<<<<<<
 *         #for f, group in enumerate(groups):
 *         #    print_parallel("-Group %i has %i results" % (f, len(group.get_wos())))
 */
  __pyx_v_N = (__pyx_v_water_orientations->dimensions[1]);
 1005:         #for f, group in enumerate(groups):
 1006:         #    print_parallel("-Group %i has %i results" % (f, len(group.get_wos())))
 1007: 
 1008:         #if not scatter:
 1009:         #    groups = merge(comm.allgather(groups))
 1010:         #    groups = merge_groups(groups)
 1011:         if size > 1 and scatter:
  /* "water_algorithm_cython.pyx":1011
 *         #    groups = merge(comm.allgather(groups))
 *         #    groups = merge_groups(groups)
 *         if size > 1 and scatter:             # <<<<<<<<<<<<<<
 *             # Remove equal groups
 *             groups = comm.gather(groups, root = 0)
 */
  __pyx_t_13 = (size > 1);
  if (__pyx_t_13) {
    __pyx_t_14 = __pyx_v_scatter;
  } else {
    __pyx_t_14 = __pyx_t_13;
  }
  if (__pyx_t_14) {
 1012:             # Remove equal groups
 1013:             groups = comm.gather(groups, root = 0)
    /* "water_algorithm_cython.pyx":1013
 *         if size > 1 and scatter:
 *             # Remove equal groups
 *             groups = comm.gather(groups, root = 0)             # <<<<<<<<<<<<<<
 *             if rank == 0:
 *                 # merge the list
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__gather); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_groups));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_groups));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_groups));
    __pyx_v_groups = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
 1014:             if rank == 0:
    /* "water_algorithm_cython.pyx":1014
 *             # Remove equal groups
 *             groups = comm.gather(groups, root = 0)
 *             if rank == 0:             # <<<<<<<<<<<<<<
 *                 # merge the list
 *                 groups = merge(groups)
 */
    __pyx_t_14 = (rank == 0);
    if (__pyx_t_14) {
 1015:                 # merge the list
 1016:                 groups = merge(groups)
      /* "water_algorithm_cython.pyx":1016
 *             if rank == 0:
 *                 # merge the list
 *                 groups = merge(groups)             # <<<<<<<<<<<<<<
 *                 #for f, group in enumerate(groups):
 *                 #    print_parallel("Group %i has %i results" % (f, len(group.get_wos())), self.logfile)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__merge); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_groups));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_groups));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
      __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_groups));
      __pyx_v_groups = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;
 1017:                 #for f, group in enumerate(groups):
 1018:                 #    print_parallel("Group %i has %i results" % (f, len(group.get_wos())), self.logfile)
 1019:                 # merge equal groups
 1020: 
 1021:                 groups = merge_groups(groups)
      /* "water_algorithm_cython.pyx":1021
 *                 # merge equal groups
 * 
 *                 groups = merge_groups(groups)             # <<<<<<<<<<<<<<
 *                 group_count = len(groups)
 *             else:
 */
      __pyx_t_5 = ((PyObject *)__pyx_f_19result_group_cython_merge_groups(__pyx_v_groups)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_v_groups));
      __pyx_v_groups = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;
 1022:                 group_count = len(groups)
      /* "water_algorithm_cython.pyx":1022
 * 
 *                 groups = merge_groups(groups)
 *                 group_count = len(groups)             # <<<<<<<<<<<<<<
 *             else:
 *                 group_count = -1
 */
      if (unlikely(((PyObject *)__pyx_v_groups) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_15 = PyList_GET_SIZE(((PyObject *)__pyx_v_groups)); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_v_group_count = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L7;
    }
    /*else*/ {
 1023:             else:
 1024:                 group_count = -1
      /* "water_algorithm_cython.pyx":1024
 *                 group_count = len(groups)
 *             else:
 *                 group_count = -1             # <<<<<<<<<<<<<<
 *                 groups = []
 * 
 */
      __Pyx_INCREF(__pyx_int_neg_1);
      __pyx_v_group_count = __pyx_int_neg_1;
 1025:                 groups = []
      /* "water_algorithm_cython.pyx":1025
 *             else:
 *                 group_count = -1
 *                 groups = []             # <<<<<<<<<<<<<<
 * 
 *             #for f, group in enumerate(groups):
 */
      __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_v_groups));
      __pyx_v_groups = ((PyObject*)__pyx_t_5);
      __pyx_t_5 = 0;
    }
    __pyx_L7:;
 1026: 
 1027:             #for f, group in enumerate(groups):
 1028:             #    print_parallel("Group %i has %i results" % (f, len(group.get_wos())))
 1029:             groups = comm.scatter(split_list(groups,  size),  root = 0)
    /* "water_algorithm_cython.pyx":1029
 *             #for f, group in enumerate(groups):
 *             #    print_parallel("Group %i has %i results" % (f, len(group.get_wos())))
 *             groups = comm.scatter(split_list(groups,  size),  root = 0)             # <<<<<<<<<<<<<<
 *             group_count = comm.bcast(group_count, root = 0)
 *             #print_parallel("First scatter done: split %i groups for %i processors. Total %i wos handled." % (group_count, size, counter))
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyInt_FromLong(size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_groups));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_groups));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_groups));
    __pyx_v_groups = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
 1030:             group_count = comm.bcast(group_count, root = 0)
    /* "water_algorithm_cython.pyx":1030
 *             #    print_parallel("Group %i has %i results" % (f, len(group.get_wos())))
 *             groups = comm.scatter(split_list(groups,  size),  root = 0)
 *             group_count = comm.bcast(group_count, root = 0)             # <<<<<<<<<<<<<<
 *             #print_parallel("First scatter done: split %i groups for %i processors. Total %i wos handled." % (group_count, size, counter))
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_group_count);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_group_count);
    __Pyx_GIVEREF(__pyx_v_group_count);
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_group_count);
    __pyx_v_group_count = __pyx_t_5;
    __pyx_t_5 = 0;
 1031:             #print_parallel("First scatter done: split %i groups for %i processors. Total %i wos handled." % (group_count, size, counter))
 1032: 
 1033:             # Do scattering as long as each processor has at least 3 groups
 1034:             #   - if number of results is over 500
 1035:             # This is done to equalize the load for each processor
 1036: 
 1037:             while wo_count > 500 and group_count < 3*size and depth < 20 and depth < depth_limit and size != 1:
    /* "water_algorithm_cython.pyx":1037
 *             # This is done to equalize the load for each processor
 * 
 *             while wo_count > 500 and group_count < 3*size and depth < 20 and depth < depth_limit and size != 1:             # <<<<<<<<<<<<<<
 *                 new_groups = []
 *                 for group in groups:
 */
    while (1) {
      __pyx_t_14 = (__pyx_v_wo_count > 500);
      if (__pyx_t_14) {
        __pyx_t_5 = PyInt_FromLong((3 * size)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = PyObject_RichCompare(__pyx_v_group_count, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_13) {
          __pyx_t_16 = (__pyx_v_depth < 20);
          if (__pyx_t_16) {
            __pyx_t_17 = (__pyx_v_depth < __pyx_v_depth_limit);
            if (__pyx_t_17) {
              __pyx_t_18 = (size != 1);
              __pyx_t_19 = __pyx_t_18;
            } else {
              __pyx_t_19 = __pyx_t_17;
            }
            __pyx_t_17 = __pyx_t_19;
          } else {
            __pyx_t_17 = __pyx_t_16;
          }
          __pyx_t_16 = __pyx_t_17;
        } else {
          __pyx_t_16 = __pyx_t_13;
        }
        __pyx_t_13 = __pyx_t_16;
      } else {
        __pyx_t_13 = __pyx_t_14;
      }
      if (!__pyx_t_13) break;
 1038:                 new_groups = []
      /* "water_algorithm_cython.pyx":1038
 * 
 *             while wo_count > 500 and group_count < 3*size and depth < 20 and depth < depth_limit and size != 1:
 *                 new_groups = []             # <<<<<<<<<<<<<<
 *                 for group in groups:
 *                     for i, wo in enumerate(group.get_wos()):
 */
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF(((PyObject *)__pyx_v_new_groups));
      __pyx_v_new_groups = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
 1039:                 for group in groups:
      /* "water_algorithm_cython.pyx":1039
 *             while wo_count > 500 and group_count < 3*size and depth < 20 and depth < depth_limit and size != 1:
 *                 new_groups = []
 *                 for group in groups:             # <<<<<<<<<<<<<<
 *                     for i, wo in enumerate(group.get_wos()):
 *                         if group.bvs != None and len(group.bvs) > 0:
 */
      if (unlikely(((PyObject *)__pyx_v_groups) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = ((PyObject *)__pyx_v_groups); __Pyx_INCREF(__pyx_t_4); __pyx_t_15 = 0;
      for (;;) {
        if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
        if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_19result_group_cython_ResultGroup))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_XDECREF(((PyObject *)__pyx_v_group));
        __pyx_v_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_5);
        __pyx_t_5 = 0;
 1040:                     for i, wo in enumerate(group.get_wos()):
        /* "water_algorithm_cython.pyx":1040
 *                 new_groups = []
 *                 for group in groups:
 *                     for i, wo in enumerate(group.get_wos()):             # <<<<<<<<<<<<<<
 *                         if group.bvs != None and len(group.bvs) > 0:
 *                             rg = group._try_subgroups(group.bvs[i], 1)
 */
        __pyx_t_7 = 0;
        __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->get_wos(__pyx_v_group)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
          __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_20 = 0;
          __pyx_t_21 = NULL;
        } else {
          __pyx_t_20 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_21 = Py_TYPE(__pyx_t_1)->tp_iternext;
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        for (;;) {
          if (!__pyx_t_21 && PyList_CheckExact(__pyx_t_1)) {
            if (__pyx_t_20 >= PyList_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_20); __Pyx_INCREF(__pyx_t_5); __pyx_t_20++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_20); __pyx_t_20++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #endif
          } else if (!__pyx_t_21 && PyTuple_CheckExact(__pyx_t_1)) {
            if (__pyx_t_20 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_20); __Pyx_INCREF(__pyx_t_5); __pyx_t_20++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_20); __pyx_t_20++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #endif
          } else {
            __pyx_t_5 = __pyx_t_21(__pyx_t_1);
            if (unlikely(!__pyx_t_5)) {
              if (PyErr_Occurred()) {
                if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_XDECREF(__pyx_v_wo);
          __pyx_v_wo = __pyx_t_5;
          __pyx_t_5 = 0;
          __pyx_v_i = __pyx_t_7;
          __pyx_t_7 = (__pyx_t_7 + 1);
 1041:                         if group.bvs != None and len(group.bvs) > 0:
          /* "water_algorithm_cython.pyx":1041
 *                 for group in groups:
 *                     for i, wo in enumerate(group.get_wos()):
 *                         if group.bvs != None and len(group.bvs) > 0:             # <<<<<<<<<<<<<<
 *                             rg = group._try_subgroups(group.bvs[i], 1)
 *                             rg.add_result(wo, group.bvs[i])
 */
          __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_group->bvs), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (__pyx_t_13) {
            __pyx_t_5 = ((PyObject *)__pyx_v_group->bvs);
            __Pyx_INCREF(__pyx_t_5);
            if (unlikely(__pyx_t_5 == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_22 = PyList_GET_SIZE(__pyx_t_5); if (unlikely(__pyx_t_22 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_14 = (__pyx_t_22 > 0);
            __pyx_t_16 = __pyx_t_14;
          } else {
            __pyx_t_16 = __pyx_t_13;
          }
          if (__pyx_t_16) {
 1042:                             rg = group._try_subgroups(group.bvs[i], 1)
            /* "water_algorithm_cython.pyx":1042
 *                     for i, wo in enumerate(group.get_wos()):
 *                         if group.bvs != None and len(group.bvs) > 0:
 *                             rg = group._try_subgroups(group.bvs[i], 1)             # <<<<<<<<<<<<<<
 *                             rg.add_result(wo, group.bvs[i])
 *                         else:
 */
            if (unlikely(((PyObject *)__pyx_v_group->bvs) == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(PyList_GET_ITEM(__pyx_v_group->bvs, __pyx_v_i));
            if (unlikely(!__pyx_t_23.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_5 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->_try_subgroups(__pyx_v_group, __pyx_t_23, 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1);
            __Pyx_XDECREF(((PyObject *)__pyx_v_rg));
            __pyx_v_rg = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_5);
            __pyx_t_5 = 0;
 1043:                             rg.add_result(wo, group.bvs[i])
            /* "water_algorithm_cython.pyx":1043
 *                         if group.bvs != None and len(group.bvs) > 0:
 *                             rg = group._try_subgroups(group.bvs[i], 1)
 *                             rg.add_result(wo, group.bvs[i])             # <<<<<<<<<<<<<<
 *                         else:
 *                             get_bond_variables_3(wo,  self.nearest_neighbors_nos, N, bond_variables)
 */
            if (!(likely(((__pyx_v_wo) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_wo, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            if (unlikely(((PyObject *)__pyx_v_group->bvs) == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_24 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(PyList_GET_ITEM(__pyx_v_group->bvs, __pyx_v_i));
            if (unlikely(!__pyx_t_24.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_rg->__pyx_vtab)->add_result(__pyx_v_rg, ((PyArrayObject *)__pyx_v_wo), __pyx_t_24);
            __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1);
            goto __pyx_L14;
          }
          /*else*/ {
 1044:                         else:
 1045:                             get_bond_variables_3(wo,  self.nearest_neighbors_nos, N, bond_variables)
            /* "water_algorithm_cython.pyx":1045
 *                             rg.add_result(wo, group.bvs[i])
 *                         else:
 *                             get_bond_variables_3(wo,  self.nearest_neighbors_nos, N, bond_variables)             # <<<<<<<<<<<<<<
 *                             rg = group._try_subgroups(bond_variables.base, 1)
 *                             rg.add_result(wo, None)
 */
            __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_wo);
            if (unlikely(!__pyx_t_25.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_26 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_5);
            if (unlikely(!__pyx_t_26.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_25, __pyx_t_26, __pyx_v_N, __pyx_v_bond_variables);
            __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
            __PYX_XDEC_MEMVIEW(&__pyx_t_26, 1);
 1046:                             rg = group._try_subgroups(bond_variables.base, 1)
            /* "water_algorithm_cython.pyx":1046
 *                         else:
 *                             get_bond_variables_3(wo,  self.nearest_neighbors_nos, N, bond_variables)
 *                             rg = group._try_subgroups(bond_variables.base, 1)             # <<<<<<<<<<<<<<
 *                             rg.add_result(wo, None)
 *                     group.bvs = None
 */
            __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_bond_variables, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__base); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(__pyx_t_3);
            if (unlikely(!__pyx_t_23.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->_try_subgroups(__pyx_v_group, __pyx_t_23, 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1);
            __Pyx_XDECREF(((PyObject *)__pyx_v_rg));
            __pyx_v_rg = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_3);
            __pyx_t_3 = 0;
 1047:                             rg.add_result(wo, None)
            /* "water_algorithm_cython.pyx":1047
 *                             get_bond_variables_3(wo,  self.nearest_neighbors_nos, N, bond_variables)
 *                             rg = group._try_subgroups(bond_variables.base, 1)
 *                             rg.add_result(wo, None)             # <<<<<<<<<<<<<<
 *                     group.bvs = None
 *                     group.wos = None
 */
            if (!(likely(((__pyx_v_wo) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_wo, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_24 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(Py_None);
            if (unlikely(!__pyx_t_24.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_rg->__pyx_vtab)->add_result(__pyx_v_rg, ((PyArrayObject *)__pyx_v_wo), __pyx_t_24);
            __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1);
          }
          __pyx_L14:;
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1048:                     group.bvs = None
        /* "water_algorithm_cython.pyx":1048
 *                             rg = group._try_subgroups(bond_variables.base, 1)
 *                             rg.add_result(wo, None)
 *                     group.bvs = None             # <<<<<<<<<<<<<<
 *                     group.wos = None
 *                     new_groups.extend(group.get_subgroups_from_level(0))
 */
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        __Pyx_GOTREF(__pyx_v_group->bvs);
        __Pyx_DECREF(((PyObject *)__pyx_v_group->bvs));
        __pyx_v_group->bvs = ((PyObject*)Py_None);
 1049:                     group.wos = None
        /* "water_algorithm_cython.pyx":1049
 *                             rg.add_result(wo, None)
 *                     group.bvs = None
 *                     group.wos = None             # <<<<<<<<<<<<<<
 *                     new_groups.extend(group.get_subgroups_from_level(0))
 *                 groups = comm.gather(new_groups, root = 0)
 */
        __Pyx_INCREF(Py_None);
        __Pyx_GIVEREF(Py_None);
        __Pyx_GOTREF(__pyx_v_group->wos);
        __Pyx_DECREF(((PyObject *)__pyx_v_group->wos));
        __pyx_v_group->wos = ((PyArrayObject *)Py_None);
 1050:                     new_groups.extend(group.get_subgroups_from_level(0))
        /* "water_algorithm_cython.pyx":1050
 *                     group.bvs = None
 *                     group.wos = None
 *                     new_groups.extend(group.get_subgroups_from_level(0))             # <<<<<<<<<<<<<<
 *                 groups = comm.gather(new_groups, root = 0)
 *                 group_count = -1
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_new_groups), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->get_subgroups_from_level(__pyx_v_group, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1051:                 groups = comm.gather(new_groups, root = 0)
      /* "water_algorithm_cython.pyx":1051
 *                     group.wos = None
 *                     new_groups.extend(group.get_subgroups_from_level(0))
 *                 groups = comm.gather(new_groups, root = 0)             # <<<<<<<<<<<<<<
 *                 group_count = -1
 *                 if rank == 0:
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__gather); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_new_groups));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_new_groups));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_new_groups));
      __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_groups));
      __pyx_v_groups = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;
 1052:                 group_count = -1
      /* "water_algorithm_cython.pyx":1052
 *                     new_groups.extend(group.get_subgroups_from_level(0))
 *                 groups = comm.gather(new_groups, root = 0)
 *                 group_count = -1             # <<<<<<<<<<<<<<
 *                 if rank == 0:
 *                     groups = merge(groups)
 */
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_DECREF(__pyx_v_group_count);
      __pyx_v_group_count = __pyx_int_neg_1;
 1053:                 if rank == 0:
      /* "water_algorithm_cython.pyx":1053
 *                 groups = comm.gather(new_groups, root = 0)
 *                 group_count = -1
 *                 if rank == 0:             # <<<<<<<<<<<<<<
 *                     groups = merge(groups)
 *                     group_count = len(groups)
 */
      __pyx_t_16 = (rank == 0);
      if (__pyx_t_16) {
 1054:                     groups = merge(groups)
        /* "water_algorithm_cython.pyx":1054
 *                 group_count = -1
 *                 if rank == 0:
 *                     groups = merge(groups)             # <<<<<<<<<<<<<<
 *                     group_count = len(groups)
 *                     if group_count > 3*size:
 */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__merge); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(((PyObject *)__pyx_v_groups));
        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_groups));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
        __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
        if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_groups));
        __pyx_v_groups = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
 1055:                     group_count = len(groups)
        /* "water_algorithm_cython.pyx":1055
 *                 if rank == 0:
 *                     groups = merge(groups)
 *                     group_count = len(groups)             # <<<<<<<<<<<<<<
 *                     if group_count > 3*size:
 *                         for i, group in enumerate(groups):
 */
        if (unlikely(((PyObject *)__pyx_v_groups) == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_15 = PyList_GET_SIZE(((PyObject *)__pyx_v_groups)); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_v_group_count);
        __pyx_v_group_count = __pyx_t_3;
        __pyx_t_3 = 0;
 1056:                     if group_count > 3*size:
        /* "water_algorithm_cython.pyx":1056
 *                     groups = merge(groups)
 *                     group_count = len(groups)
 *                     if group_count > 3*size:             # <<<<<<<<<<<<<<
 *                         for i, group in enumerate(groups):
 *                             self.save_results(0, group.get_wos(), None, group_save=True, group_number=i)
 */
        __pyx_t_3 = PyInt_FromLong((3 * size)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = PyObject_RichCompare(__pyx_v_group_count, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_16) {
 1057:                         for i, group in enumerate(groups):
          /* "water_algorithm_cython.pyx":1057
 *                     group_count = len(groups)
 *                     if group_count > 3*size:
 *                         for i, group in enumerate(groups):             # <<<<<<<<<<<<<<
 *                             self.save_results(0, group.get_wos(), None, group_save=True, group_number=i)
 *                     groups = split_list(groups, size)
 */
          __pyx_t_7 = 0;
          __pyx_t_5 = ((PyObject *)__pyx_v_groups); __Pyx_INCREF(__pyx_t_5); __pyx_t_15 = 0;
          for (;;) {
            if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_5)) break;
            #if CYTHON_COMPILING_IN_CPYTHON
            __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #else
            __pyx_t_3 = PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            #endif
            if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_19result_group_cython_ResultGroup))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_XDECREF(((PyObject *)__pyx_v_group));
            __pyx_v_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_3);
            __pyx_t_3 = 0;
            __pyx_v_i = __pyx_t_7;
            __pyx_t_7 = (__pyx_t_7 + 1);
 1058:                             self.save_results(0, group.get_wos(), None, group_save=True, group_number=i)
            /* "water_algorithm_cython.pyx":1058
 *                     if group_count > 3*size:
 *                         for i, group in enumerate(groups):
 *                             self.save_results(0, group.get_wos(), None, group_save=True, group_number=i)             # <<<<<<<<<<<<<<
 *                     groups = split_list(groups, size)
 *                 group_count = gather_and_max(group_count)
 */
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__save_results); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->get_wos(__pyx_v_group)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(__pyx_int_0);
            PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
            __Pyx_GIVEREF(__pyx_int_0);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_INCREF(Py_None);
            PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
            __Pyx_GIVEREF(Py_None);
            __pyx_t_1 = 0;
            __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_1));
            __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__group_save), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__group_number), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L16;
        }
        __pyx_L16:;
 1059:                     groups = split_list(groups, size)
        /* "water_algorithm_cython.pyx":1059
 *                         for i, group in enumerate(groups):
 *                             self.save_results(0, group.get_wos(), None, group_save=True, group_number=i)
 *                     groups = split_list(groups, size)             # <<<<<<<<<<<<<<
 *                 group_count = gather_and_max(group_count)
 * 
 */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyInt_FromLong(size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(((PyObject *)__pyx_v_groups));
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_groups));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_groups));
        __pyx_v_groups = ((PyObject*)__pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L15;
      }
      __pyx_L15:;
 1060:                 group_count = gather_and_max(group_count)
      /* "water_algorithm_cython.pyx":1060
 *                             self.save_results(0, group.get_wos(), None, group_save=True, group_number=i)
 *                     groups = split_list(groups, size)
 *                 group_count = gather_and_max(group_count)             # <<<<<<<<<<<<<<
 * 
 *                 groups = comm.scatter(groups,  root = 0)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_max); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_group_count);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_group_count);
      __Pyx_GIVEREF(__pyx_v_group_count);
      __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_group_count);
      __pyx_v_group_count = __pyx_t_5;
      __pyx_t_5 = 0;
 1061: 
 1062:                 groups = comm.scatter(groups,  root = 0)
      /* "water_algorithm_cython.pyx":1062
 *                 group_count = gather_and_max(group_count)
 * 
 *                 groups = comm.scatter(groups,  root = 0)             # <<<<<<<<<<<<<<
 *                 depth += 1
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_groups));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_groups));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_groups));
      __pyx_v_groups = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;
 1063:                 depth += 1
      /* "water_algorithm_cython.pyx":1063
 * 
 *                 groups = comm.scatter(groups,  root = 0)
 *                 depth += 1             # <<<<<<<<<<<<<<
 * 
 *             #print_parallel("Results split in %i groups after %i iterations" % (group_count, depth))
 */
      __pyx_v_depth = (__pyx_v_depth + 1);
    }
    goto __pyx_L6;
  }
  __pyx_L6:;
 1064: 
 1065:             #print_parallel("Results split in %i groups after %i iterations" % (group_count, depth))
 1066: 
 1067:         return groups, depth
  /* "water_algorithm_cython.pyx":1067
 *             #print_parallel("Results split in %i groups after %i iterations" % (group_count, depth))
 * 
 *         return groups, depth             # <<<<<<<<<<<<<<
 * 
 *     cdef tuple handle_self_symmetry_group(self, SelfSymmetryGroup self_symmetry_group, list symmetry_operations, list new_symmetry_operations, DTYPE2_t[:, ::1] water_orientations, list new_self_symmetry_groups, int result_group_count, unsigned char molecule_no, ResultGroup main_result_group, bint save_self_symmetry_groups, bint all_symmetries_found, DTYPE_t[::1] nn, int child_level, DTYPE_t [:, :, ::1] possible_combinations):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_4 = PyInt_FromLong(__pyx_v_depth); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_groups));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_groups));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_groups));
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_26, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.do_initial_grouping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientation, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_group);
  __Pyx_XDECREF((PyObject *)__pyx_v_rg);
  __Pyx_XDECREF(__pyx_v_groups);
  __Pyx_XDECREF(__pyx_v_new_groups);
  __Pyx_XDECREF(__pyx_v_group_count);
  __Pyx_XDECREF(__pyx_v_wo);
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientations);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1068: 
 1069:     cdef tuple handle_self_symmetry_group(self, SelfSymmetryGroup self_symmetry_group, list symmetry_operations, list new_symmetry_operations, DTYPE2_t[:, ::1] water_orientations, list new_self_symmetry_groups, int result_group_count, unsigned char molecule_no, ResultGroup main_result_group, bint save_self_symmetry_groups, bint all_symmetries_found, DTYPE_t[::1] nn, int child_level, DTYPE_t [:, :, ::1] possible_combinations):
/* "water_algorithm_cython.pyx":1069
 *         return groups, depth
 * 
 *     cdef tuple handle_self_symmetry_group(self, SelfSymmetryGroup self_symmetry_group, list symmetry_operations, list new_symmetry_operations, DTYPE2_t[:, ::1] water_orientations, list new_self_symmetry_groups, int result_group_count, unsigned char molecule_no, ResultGroup main_result_group, bint save_self_symmetry_groups, bint all_symmetries_found, DTYPE_t[::1] nn, int child_level, DTYPE_t [:, :, ::1] possible_combinations):             # <<<<<<<<<<<<<<
 *         """
 *             Handles a single self symmetry group and it's subgroups
 */

static PyObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_handle_self_symmetry_group(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_self_symmetry_group, PyObject *__pyx_v_symmetry_operations, PyObject *__pyx_v_new_symmetry_operations, __Pyx_memviewslice __pyx_v_water_orientations, PyObject *__pyx_v_new_self_symmetry_groups, int __pyx_v_result_group_count, unsigned char __pyx_v_molecule_no, struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_main_result_group, int __pyx_v_save_self_symmetry_groups, int __pyx_v_all_symmetries_found, __Pyx_memviewslice __pyx_v_nn, int __pyx_v_child_level, __Pyx_memviewslice __pyx_v_possible_combinations) {
  __Pyx_memviewslice __pyx_v_new_water_orientations = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_wos = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_tested_symmetry_operations = 0;
  PyObject *__pyx_v_leftover_symmetry_operations = 0;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_Q;
  int __pyx_v_P;
  int __pyx_v_discarded;
  PyObject *__pyx_v_child_self_symmetry_groups = 0;
  int __pyx_v_scatter;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_group = 0;
  struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_child_self_symmetry_group = 0;
  struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_parent_self_symmetry_group = 0;
  PyObject *__pyx_v_graph_invariants = 0;
  PyObject *__pyx_v_child_empty = 0;
  int __pyx_v_child_l;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_self_symmetry_group", 0);
  __PYX_INC_MEMVIEW(&__pyx_v_water_orientations, 1);
 1070:         """
 1071:             Handles a single self symmetry group and it's subgroups
 1072:             Parameters:
 1073:                 symmetry_operations: all possible symmetry operations at current phase of execution, before removing earlier found
 1074:                 self_symmetry_group: the self symmetry group handled
 1075:                 new_symmetry_operations: the operations that are new in the current phase of execution
 1076:                 water_orientations: the water orientations from main thread
 1077:                 new_symmetry_groups: new symmetry groups found during handling of all self symmetry groups
 1078:         """
 1079: 
 1080:         cdef DTYPE2_t[:, ::1] new_water_orientations, wos
 1081:         cdef list tested_symmetry_operations, leftover_symmetry_operations
 1082:         cdef int i, j, k, l, O, Q, P = len(self_symmetry_group.child_self_symmetry_groups), discarded = 0
  /* "water_algorithm_cython.pyx":1082
 *         cdef DTYPE2_t[:, ::1] new_water_orientations, wos
 *         cdef list tested_symmetry_operations, leftover_symmetry_operations
 *         cdef int i, j, k, l, O, Q, P = len(self_symmetry_group.child_self_symmetry_groups), discarded = 0             # <<<<<<<<<<<<<<
 *         cdef list child_self_symmetry_groups = []
 *         cdef bint scatter = False
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self_symmetry_group->child_self_symmetry_groups);
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_P = __pyx_t_2;
  __pyx_v_discarded = 0;
 1083:         cdef list child_self_symmetry_groups = []
  /* "water_algorithm_cython.pyx":1083
 *         cdef list tested_symmetry_operations, leftover_symmetry_operations
 *         cdef int i, j, k, l, O, Q, P = len(self_symmetry_group.child_self_symmetry_groups), discarded = 0
 *         cdef list child_self_symmetry_groups = []             # <<<<<<<<<<<<<<
 *         cdef bint scatter = False
 *         #cdef np.ndarray[DTYPE2_t, ndim=2] bond_variables
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_child_self_symmetry_groups = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 1084:         cdef bint scatter = False
  /* "water_algorithm_cython.pyx":1084
 *         cdef int i, j, k, l, O, Q, P = len(self_symmetry_group.child_self_symmetry_groups), discarded = 0
 *         cdef list child_self_symmetry_groups = []
 *         cdef bint scatter = False             # <<<<<<<<<<<<<<
 *         #cdef np.ndarray[DTYPE2_t, ndim=2] bond_variables
 *         cdef ResultGroup rg, group
 */
  __pyx_v_scatter = 0;
 1085:         #cdef np.ndarray[DTYPE2_t, ndim=2] bond_variables
 1086:         cdef ResultGroup rg, group
 1087:         cdef SelfSymmetryGroup child_self_symmetry_group, parent_self_symmetry_group
 1088:         tested_symmetry_operations, leftover_symmetry_operations = self_symmetry_group.get_tested_and_leftover_symmetry_operations(symmetry_operations)
  /* "water_algorithm_cython.pyx":1088
 *         cdef ResultGroup rg, group
 *         cdef SelfSymmetryGroup child_self_symmetry_group, parent_self_symmetry_group
 *         tested_symmetry_operations, leftover_symmetry_operations = self_symmetry_group.get_tested_and_leftover_symmetry_operations(symmetry_operations)             # <<<<<<<<<<<<<<
 *         cdef list graph_invariants = self.graph_invariants
 *         # Do iteration of water orientations
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_v_self_symmetry_group->__pyx_vtab)->get_tested_and_leftover_symmetry_operations(__pyx_v_self_symmetry_group, __pyx_v_symmetry_operations)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (likely(PyTuple_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else if (1) {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = NULL;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyList_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_tested_symmetry_operations = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_leftover_symmetry_operations = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
 1089:         cdef list graph_invariants = self.graph_invariants
  /* "water_algorithm_cython.pyx":1089
 *         cdef SelfSymmetryGroup child_self_symmetry_group, parent_self_symmetry_group
 *         tested_symmetry_operations, leftover_symmetry_operations = self_symmetry_group.get_tested_and_leftover_symmetry_operations(symmetry_operations)
 *         cdef list graph_invariants = self.graph_invariants             # <<<<<<<<<<<<<<
 *         # Do iteration of water orientations
 *         if size > 1:
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->graph_invariants);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_graph_invariants = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 1090:         # Do iteration of water orientations
 1091:         if size > 1:
  /* "water_algorithm_cython.pyx":1091
 *         cdef list graph_invariants = self.graph_invariants
 *         # Do iteration of water orientations
 *         if size > 1:             # <<<<<<<<<<<<<<
 *             wos = comm.scatter(split_list(self_symmetry_group.water_orientations,  size),  root = 0)
 *         else:
 */
  __pyx_t_7 = (size > 1);
  if (__pyx_t_7) {
 1092:             wos = comm.scatter(split_list(self_symmetry_group.water_orientations,  size),  root = 0)
    /* "water_algorithm_cython.pyx":1092
 *         # Do iteration of water orientations
 *         if size > 1:
 *             wos = comm.scatter(split_list(self_symmetry_group.water_orientations,  size),  root = 0)             # <<<<<<<<<<<<<<
 *         else:
 *             wos = self_symmetry_group.water_orientations
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong(size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
    if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_wos = __pyx_t_8;
    __pyx_t_8.memview = NULL;
    __pyx_t_8.data = NULL;
    goto __pyx_L5;
  }
  /*else*/ {
 1093:         else:
 1094:             wos = self_symmetry_group.water_orientations
    /* "water_algorithm_cython.pyx":1094
 *             wos = comm.scatter(split_list(self_symmetry_group.water_orientations,  size),  root = 0)
 *         else:
 *             wos = self_symmetry_group.water_orientations             # <<<<<<<<<<<<<<
 *         new_water_orientations = self.handle_molecule_algorithm_2(molecule_no, wos, possible_combinations, nn, False, &discarded)
 *         if size > 1:
 */
    __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
    if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_wos = __pyx_t_8;
    __pyx_t_8.memview = NULL;
    __pyx_t_8.data = NULL;
  }
  __pyx_L5:;
 1095:         new_water_orientations = self.handle_molecule_algorithm_2(molecule_no, wos, possible_combinations, nn, False, &discarded)
  /* "water_algorithm_cython.pyx":1095
 *         else:
 *             wos = self_symmetry_group.water_orientations
 *         new_water_orientations = self.handle_molecule_algorithm_2(molecule_no, wos, possible_combinations, nn, False, &discarded)             # <<<<<<<<<<<<<<
 *         if size > 1:
 *             discarded = gather_and_sum(discarded)
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->handle_molecule_algorithm_2(__pyx_v_self, __pyx_v_molecule_no, __pyx_v_wos, __pyx_v_possible_combinations, __pyx_v_nn, 0, (&__pyx_v_discarded))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
  if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_new_water_orientations = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 1096:         if size > 1:
  /* "water_algorithm_cython.pyx":1096
 *             wos = self_symmetry_group.water_orientations
 *         new_water_orientations = self.handle_molecule_algorithm_2(molecule_no, wos, possible_combinations, nn, False, &discarded)
 *         if size > 1:             # <<<<<<<<<<<<<<
 *             discarded = gather_and_sum(discarded)
 *             new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations.base))
 */
  __pyx_t_7 = (size > 1);
  if (__pyx_t_7) {
 1097:             discarded = gather_and_sum(discarded)
    /* "water_algorithm_cython.pyx":1097
 *         new_water_orientations = self.handle_molecule_algorithm_2(molecule_no, wos, possible_combinations, nn, False, &discarded)
 *         if size > 1:
 *             discarded = gather_and_sum(discarded)             # <<<<<<<<<<<<<<
 *             new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations.base))
 *         #print_parallel(new_water_orientations, self.logfile)
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__gather_and_sum); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_discarded); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_discarded = __pyx_t_9;
 1098:             new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations.base))
    /* "water_algorithm_cython.pyx":1098
 *         if size > 1:
 *             discarded = gather_and_sum(discarded)
 *             new_water_orientations = merge_water_orientations(comm.allgather(new_water_orientations.base))             # <<<<<<<<<<<<<<
 *         #print_parallel(new_water_orientations, self.logfile)
 *         #print_parallel("Discarded %i geometries due to breakage of ice rules, resulted %i geometries" % (discarded, new_water_orientations.shape[0]), self.logfile)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_67); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__allgather); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_1);
    if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
    __pyx_v_new_water_orientations = __pyx_t_8;
    __pyx_t_8.memview = NULL;
    __pyx_t_8.data = NULL;
    goto __pyx_L6;
  }
  __pyx_L6:;
 1099:         #print_parallel(new_water_orientations, self.logfile)
 1100:         #print_parallel("Discarded %i geometries due to breakage of ice rules, resulted %i geometries" % (discarded, new_water_orientations.shape[0]), self.logfile)
 1101:         self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]>new_water_orientations.base
  /* "water_algorithm_cython.pyx":1101
 *         #print_parallel(new_water_orientations, self.logfile)
 *         #print_parallel("Discarded %i geometries due to breakage of ice rules, resulted %i geometries" % (discarded, new_water_orientations.shape[0]), self.logfile)
 *         self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]>new_water_orientations.base             # <<<<<<<<<<<<<<
 *         group = None
 *         cdef str child_empty = ""
 */
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_t_4)));
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self_symmetry_group->water_orientations);
  __Pyx_DECREF(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
  __pyx_v_self_symmetry_group->water_orientations = ((PyArrayObject *)__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1102:         group = None
  /* "water_algorithm_cython.pyx":1102
 *         #print_parallel("Discarded %i geometries due to breakage of ice rules, resulted %i geometries" % (discarded, new_water_orientations.shape[0]), self.logfile)
 *         self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]>new_water_orientations.base
 *         group = None             # <<<<<<<<<<<<<<
 *         cdef str child_empty = ""
 *         cdef int child_l = 0
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)Py_None);
 1103:         cdef str child_empty = ""
  /* "water_algorithm_cython.pyx":1103
 *         self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]>new_water_orientations.base
 *         group = None
 *         cdef str child_empty = ""             # <<<<<<<<<<<<<<
 *         cdef int child_l = 0
 *         while child_l <= child_level:
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  __pyx_v_child_empty = __pyx_kp_s_1;
 1104:         cdef int child_l = 0
  /* "water_algorithm_cython.pyx":1104
 *         group = None
 *         cdef str child_empty = ""
 *         cdef int child_l = 0             # <<<<<<<<<<<<<<
 *         while child_l <= child_level:
 *             child_empty += "    "
 */
  __pyx_v_child_l = 0;
 1105:         while child_l <= child_level:
  /* "water_algorithm_cython.pyx":1105
 *         cdef str child_empty = ""
 *         cdef int child_l = 0
 *         while child_l <= child_level:             # <<<<<<<<<<<<<<
 *             child_empty += "    "
 *             child_l += 1
 */
  while (1) {
    __pyx_t_7 = (__pyx_v_child_l <= __pyx_v_child_level);
    if (!__pyx_t_7) break;
 1106:             child_empty += "    "
    /* "water_algorithm_cython.pyx":1106
 *         cdef int child_l = 0
 *         while child_l <= child_level:
 *             child_empty += "    "             # <<<<<<<<<<<<<<
 *             child_l += 1
 * 
 */
    __pyx_t_4 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_child_empty), ((PyObject *)__pyx_kp_s_88)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(((PyObject *)__pyx_v_child_empty));
    __pyx_v_child_empty = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 1107:             child_l += 1
    /* "water_algorithm_cython.pyx":1107
 *         while child_l <= child_level:
 *             child_empty += "    "
 *             child_l += 1             # <<<<<<<<<<<<<<
 * 
 *         # Only using the current result group if the group is left alive, otherwise a fresh result group is used
 */
    __pyx_v_child_l = (__pyx_v_child_l + 1);
  }
 1108: 
 1109:         # Only using the current result group if the group is left alive, otherwise a fresh result group is used
 1110:         if  len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:
  /* "water_algorithm_cython.pyx":1110
 * 
 *         # Only using the current result group if the group is left alive, otherwise a fresh result group is used
 *         if  len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:             # <<<<<<<<<<<<<<
 *             group = self.result_group
 *             if size > 1:
 */
  if (unlikely(((PyObject *)__pyx_v_leftover_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_leftover_symmetry_operations)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = (__pyx_t_2 == 0);
  if (__pyx_t_7) {
    __pyx_t_10 = (!__pyx_v_self_symmetry_group->finalized);
    __pyx_t_11 = __pyx_t_10;
  } else {
    __pyx_t_11 = __pyx_t_7;
  }
  if (__pyx_t_11) {
 1111:             group = self.result_group
    /* "water_algorithm_cython.pyx":1111
 *         # Only using the current result group if the group is left alive, otherwise a fresh result group is used
 *         if  len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:
 *             group = self.result_group             # <<<<<<<<<<<<<<
 *             if size > 1:
 *                 scatter = True
 */
    __pyx_t_4 = ((PyObject *)__pyx_v_self->result_group);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_v_group));
    __pyx_v_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_4);
    __pyx_t_4 = 0;
 1112:             if size > 1:
    /* "water_algorithm_cython.pyx":1112
 *         if  len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:
 *             group = self.result_group
 *             if size > 1:             # <<<<<<<<<<<<<<
 *                 scatter = True
 *             self.result_group = ResultGroup(graph_invariants,  0)
 */
    __pyx_t_11 = (size > 1);
    if (__pyx_t_11) {
 1113:                 scatter = True
      /* "water_algorithm_cython.pyx":1113
 *             group = self.result_group
 *             if size > 1:
 *                 scatter = True             # <<<<<<<<<<<<<<
 *             self.result_group = ResultGroup(graph_invariants,  0)
 *             #print_(child_empty + "Using fresh result group, rank %i" % rank, self.logfile)
 */
      __pyx_v_scatter = 1;
      goto __pyx_L10;
    }
    __pyx_L10:;
 1114:             self.result_group = ResultGroup(graph_invariants,  0)
    /* "water_algorithm_cython.pyx":1114
 *             if size > 1:
 *                 scatter = True
 *             self.result_group = ResultGroup(graph_invariants,  0)             # <<<<<<<<<<<<<<
 *             #print_(child_empty + "Using fresh result group, rank %i" % rank, self.logfile)
 * 
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_graph_invariants));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_graph_invariants));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_graph_invariants));
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_19result_group_cython_ResultGroup)), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->result_group);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
    __pyx_v_self->result_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;
 1115:             #print_(child_empty + "Using fresh result group, rank %i" % rank, self.logfile)
 1116: 
 1117: 
 1118:         # Handle child self symmetry groups
 1119:         for i from 0 <= i < P:
  /* "water_algorithm_cython.pyx":1119
 * 
 *         # Handle child self symmetry groups
 *         for i from 0 <= i < P:             # <<<<<<<<<<<<<<
 *             #print_(child_empty + "-------------------------------------------------", self.logfile)
 *             #print_(child_empty + "Handling child self symmetry group %i of %i " % (i+1, P), self.logfile)
 */
  __pyx_t_9 = __pyx_v_P;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
 1120:             #print_(child_empty + "-------------------------------------------------", self.logfile)
 1121:             #print_(child_empty + "Handling child self symmetry group %i of %i " % (i+1, P), self.logfile)
 1122:             #print_(child_empty + "-------------------------------------------------", self.logfile)
 1123:             child_self_symmetry_group = <SelfSymmetryGroup>self_symmetry_group.child_self_symmetry_groups[i]
    /* "water_algorithm_cython.pyx":1123
 *             #print_(child_empty + "Handling child self symmetry group %i of %i " % (i+1, P), self.logfile)
 *             #print_(child_empty + "-------------------------------------------------", self.logfile)
 *             child_self_symmetry_group = <SelfSymmetryGroup>self_symmetry_group.child_self_symmetry_groups[i]             # <<<<<<<<<<<<<<
 *             self.handle_self_symmetry_group(child_self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations, new_self_symmetry_groups, result_group_count, molecule_no, main_result_group, save_self_symmetry_groups, all_symmetries_found, nn, child_level + 1, possible_combinations)
 *             print_(child_empty + "-------------------------------------------------", self.logfile)
 */
    if (unlikely(((PyObject *)__pyx_v_self_symmetry_group->child_self_symmetry_groups) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = PyList_GET_ITEM(__pyx_v_self_symmetry_group->child_self_symmetry_groups, __pyx_v_i);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(((PyObject *)__pyx_v_child_self_symmetry_group));
    __pyx_v_child_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_1);
    __pyx_t_1 = 0;
 1124:             self.handle_self_symmetry_group(child_self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations, new_self_symmetry_groups, result_group_count, molecule_no, main_result_group, save_self_symmetry_groups, all_symmetries_found, nn, child_level + 1, possible_combinations)
    /* "water_algorithm_cython.pyx":1124
 *             #print_(child_empty + "-------------------------------------------------", self.logfile)
 *             child_self_symmetry_group = <SelfSymmetryGroup>self_symmetry_group.child_self_symmetry_groups[i]
 *             self.handle_self_symmetry_group(child_self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations, new_self_symmetry_groups, result_group_count, molecule_no, main_result_group, save_self_symmetry_groups, all_symmetries_found, nn, child_level + 1, possible_combinations)             # <<<<<<<<<<<<<<
 *             print_(child_empty + "-------------------------------------------------", self.logfile)
 *         cdef SymmetryOperation symo
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->handle_self_symmetry_group(__pyx_v_self, __pyx_v_child_self_symmetry_group, __pyx_v_symmetry_operations, __pyx_v_new_symmetry_operations, __pyx_v_water_orientations, __pyx_v_new_self_symmetry_groups, __pyx_v_result_group_count, __pyx_v_molecule_no, __pyx_v_main_result_group, __pyx_v_save_self_symmetry_groups, __pyx_v_all_symmetries_found, __pyx_v_nn, (__pyx_v_child_level + 1), __pyx_v_possible_combinations)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1125:             print_(child_empty + "-------------------------------------------------", self.logfile)
    /* "water_algorithm_cython.pyx":1125
 *             child_self_symmetry_group = <SelfSymmetryGroup>self_symmetry_group.child_self_symmetry_groups[i]
 *             self.handle_self_symmetry_group(child_self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations, new_self_symmetry_groups, result_group_count, molecule_no, main_result_group, save_self_symmetry_groups, all_symmetries_found, nn, child_level + 1, possible_combinations)
 *             print_(child_empty + "-------------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *         cdef SymmetryOperation symo
 *         new_water_orientations = self_symmetry_group.water_orientations
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_v_child_empty), ((PyObject *)__pyx_kp_s_89)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
 1126:         cdef SymmetryOperation symo
 1127:         new_water_orientations = self_symmetry_group.water_orientations
  /* "water_algorithm_cython.pyx":1127
 *             print_(child_empty + "-------------------------------------------------", self.logfile)
 *         cdef SymmetryOperation symo
 *         new_water_orientations = self_symmetry_group.water_orientations             # <<<<<<<<<<<<<<
 *         #print P, rank, new_water_orientations
 *         if new_water_orientations.shape[0] > 0:
 */
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
  if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
  __pyx_v_new_water_orientations = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 1128:         #print P, rank, new_water_orientations
 1129:         if new_water_orientations.shape[0] > 0:
  /* "water_algorithm_cython.pyx":1129
 *         new_water_orientations = self_symmetry_group.water_orientations
 *         #print P, rank, new_water_orientations
 *         if new_water_orientations.shape[0] > 0:             # <<<<<<<<<<<<<<
 * 
 *             # Although ther might not be any in tested_symmetry_operations the symmetry check must be performed
 */
  __pyx_t_11 = ((__pyx_v_new_water_orientations.shape[0]) > 0);
  if (__pyx_t_11) {
 1130: 
 1131:             # Although ther might not be any in tested_symmetry_operations the symmetry check must be performed
 1132:             # to group the results in this group, so that symmetries with parent groups water orientaions and
 1133:             # symmetry operations can be detected.
 1134:             tested_symmetry_operations.extend(new_symmetry_operations)
    /* "water_algorithm_cython.pyx":1134
 *             # to group the results in this group, so that symmetries with parent groups water orientaions and
 *             # symmetry operations can be detected.
 *             tested_symmetry_operations.extend(new_symmetry_operations)             # <<<<<<<<<<<<<<
 *             tested_symmetry_operations.extend(self_symmetry_group.get_active_parent_symmetry_operations(symmetry_operations))
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tested_symmetry_operations), __pyx_n_s__extend); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_new_symmetry_operations));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_new_symmetry_operations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_new_symmetry_operations));
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1135:             tested_symmetry_operations.extend(self_symmetry_group.get_active_parent_symmetry_operations(symmetry_operations))
    /* "water_algorithm_cython.pyx":1135
 *             # symmetry operations can be detected.
 *             tested_symmetry_operations.extend(new_symmetry_operations)
 *             tested_symmetry_operations.extend(self_symmetry_group.get_active_parent_symmetry_operations(symmetry_operations))             # <<<<<<<<<<<<<<
 * 
 *             new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, tested_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 20, scatter)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tested_symmetry_operations), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_v_self_symmetry_group->__pyx_vtab)->get_active_parent_symmetry_operations(__pyx_v_self_symmetry_group, __pyx_v_symmetry_operations)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1136: 
 1137:             new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, tested_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 20, scatter)
    /* "water_algorithm_cython.pyx":1137
 *             tested_symmetry_operations.extend(self_symmetry_group.get_active_parent_symmetry_operations(symmetry_operations))
 * 
 *             new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, tested_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 20, scatter)             # <<<<<<<<<<<<<<
 * 
 *             self.result_group.clear_wos_from_level(1)
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->remove_symmetric_results(__pyx_v_self, __pyx_v_new_water_orientations, __pyx_v_molecule_no, __pyx_v_tested_symmetry_operations, __pyx_v_result_group_count, __pyx_v_child_self_symmetry_groups, __pyx_v_save_self_symmetry_groups, ((PyObject*)Py_None), __pyx_v_self_symmetry_group, 20, __pyx_v_scatter)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
    if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
    __pyx_v_new_water_orientations = __pyx_t_8;
    __pyx_t_8.memview = NULL;
    __pyx_t_8.data = NULL;
 1138: 
 1139:             self.result_group.clear_wos_from_level(1)
    /* "water_algorithm_cython.pyx":1139
 *             new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, tested_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 20, scatter)
 * 
 *             self.result_group.clear_wos_from_level(1)             # <<<<<<<<<<<<<<
 * 
 *             if len(leftover_symmetry_operations) > 0 and len(new_symmetry_operations) > 0:
 */
    ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->clear_wos_from_level(__pyx_v_self->result_group, 1);
 1140: 
 1141:             if len(leftover_symmetry_operations) > 0 and len(new_symmetry_operations) > 0:
    /* "water_algorithm_cython.pyx":1141
 *             self.result_group.clear_wos_from_level(1)
 * 
 *             if len(leftover_symmetry_operations) > 0 and len(new_symmetry_operations) > 0:             # <<<<<<<<<<<<<<
 *                 new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, new_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 1, False)
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_leftover_symmetry_operations) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_leftover_symmetry_operations)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = (__pyx_t_2 > 0);
    if (__pyx_t_11) {
      if (unlikely(((PyObject *)__pyx_v_new_symmetry_operations) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_new_symmetry_operations)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = (__pyx_t_2 > 0);
      __pyx_t_10 = __pyx_t_7;
    } else {
      __pyx_t_10 = __pyx_t_11;
    }
    if (__pyx_t_10) {
 1142:                 new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, new_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 1, False)
      /* "water_algorithm_cython.pyx":1142
 * 
 *             if len(leftover_symmetry_operations) > 0 and len(new_symmetry_operations) > 0:
 *                 new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, new_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 1, False)             # <<<<<<<<<<<<<<
 * 
 *         self.result_group.clear_wos_from_level(1)
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->remove_symmetric_results(__pyx_v_self, __pyx_v_new_water_orientations, __pyx_v_molecule_no, __pyx_v_new_symmetry_operations, __pyx_v_result_group_count, __pyx_v_child_self_symmetry_groups, __pyx_v_save_self_symmetry_groups, ((PyObject*)Py_None), __pyx_v_self_symmetry_group, 1, 0)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
      if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
      __pyx_v_new_water_orientations = __pyx_t_8;
      __pyx_t_8.memview = NULL;
      __pyx_t_8.data = NULL;
      goto __pyx_L14;
    }
    __pyx_L14:;
    goto __pyx_L13;
  }
  __pyx_L13:;
 1143: 
 1144:         self.result_group.clear_wos_from_level(1)
  /* "water_algorithm_cython.pyx":1144
 *                 new_water_orientations = self.remove_symmetric_results(new_water_orientations, molecule_no, new_symmetry_operations, result_group_count, child_self_symmetry_groups, save_self_symmetry_groups, None, self_symmetry_group, 1, False)
 * 
 *         self.result_group.clear_wos_from_level(1)             # <<<<<<<<<<<<<<
 *         self_symmetry_group.child_self_symmetry_groups.extend(child_self_symmetry_groups)
 *         new_self_symmetry_groups.extend(child_self_symmetry_groups)
 */
  ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->clear_wos_from_level(__pyx_v_self->result_group, 1);
 1145:         self_symmetry_group.child_self_symmetry_groups.extend(child_self_symmetry_groups)
  /* "water_algorithm_cython.pyx":1145
 * 
 *         self.result_group.clear_wos_from_level(1)
 *         self_symmetry_group.child_self_symmetry_groups.extend(child_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *         new_self_symmetry_groups.extend(child_self_symmetry_groups)
 *         if len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self_symmetry_group->child_self_symmetry_groups), __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_child_self_symmetry_groups));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_child_self_symmetry_groups));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_self_symmetry_groups));
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1146:         new_self_symmetry_groups.extend(child_self_symmetry_groups)
  /* "water_algorithm_cython.pyx":1146
 *         self.result_group.clear_wos_from_level(1)
 *         self_symmetry_group.child_self_symmetry_groups.extend(child_self_symmetry_groups)
 *         new_self_symmetry_groups.extend(child_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *         if len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:
 *             # Switch back to original ResultGroup
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_new_self_symmetry_groups), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_child_self_symmetry_groups));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_child_self_symmetry_groups));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_self_symmetry_groups));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1147:         if len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:
  /* "water_algorithm_cython.pyx":1147
 *         self_symmetry_group.child_self_symmetry_groups.extend(child_self_symmetry_groups)
 *         new_self_symmetry_groups.extend(child_self_symmetry_groups)
 *         if len(leftover_symmetry_operations) == 0 and not self_symmetry_group.finalized:             # <<<<<<<<<<<<<<
 *             # Switch back to original ResultGroup
 * 
 */
  if (unlikely(((PyObject *)__pyx_v_leftover_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_leftover_symmetry_operations)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = (__pyx_t_2 == 0);
  if (__pyx_t_10) {
    __pyx_t_11 = (!__pyx_v_self_symmetry_group->finalized);
    __pyx_t_7 = __pyx_t_11;
  } else {
    __pyx_t_7 = __pyx_t_10;
  }
  if (__pyx_t_7) {
 1148:             # Switch back to original ResultGroup
 1149: 
 1150:             #print_(child_empty + "Falling back to previous group, rank %i" % rank, self.logfile)
 1151:             self.result_group = group
    /* "water_algorithm_cython.pyx":1151
 * 
 *             #print_(child_empty + "Falling back to previous group, rank %i" % rank, self.logfile)
 *             self.result_group = group             # <<<<<<<<<<<<<<
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
 *             self_symmetry_group.finalized = True
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_group));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_group));
    __Pyx_GOTREF(__pyx_v_self->result_group);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
    __pyx_v_self->result_group = __pyx_v_group;
 1152:             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
    /* "water_algorithm_cython.pyx":1152
 *             #print_(child_empty + "Falling back to previous group, rank %i" % rank, self.logfile)
 *             self.result_group = group
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()             # <<<<<<<<<<<<<<
 *             self_symmetry_group.finalized = True
 *             #print_(child_empty + "FINALISING SELF SYMMETRY GROUP %i" % rank, self.logfile)
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_v_self_symmetry_group->__pyx_vtab)->get_active_parent_self_symmetry_group(__pyx_v_self_symmetry_group)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_parent_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_3);
    __pyx_t_3 = 0;
 1153:             self_symmetry_group.finalized = True
    /* "water_algorithm_cython.pyx":1153
 *             self.result_group = group
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
 *             self_symmetry_group.finalized = True             # <<<<<<<<<<<<<<
 *             #print_(child_empty + "FINALISING SELF SYMMETRY GROUP %i" % rank, self.logfile)
 *             if parent_self_symmetry_group is None:
 */
    __pyx_v_self_symmetry_group->finalized = 1;
 1154:             #print_(child_empty + "FINALISING SELF SYMMETRY GROUP %i" % rank, self.logfile)
 1155:             if parent_self_symmetry_group is None:
    /* "water_algorithm_cython.pyx":1155
 *             self_symmetry_group.finalized = True
 *             #print_(child_empty + "FINALISING SELF SYMMETRY GROUP %i" % rank, self.logfile)
 *             if parent_self_symmetry_group is None:             # <<<<<<<<<<<<<<
 *                 #print_(child_empty + "to main thread, rank: %i" % rank, self.logfile)
 *                 if all_symmetries_found and size > 1:
 */
    __pyx_t_7 = (((PyObject *)__pyx_v_parent_self_symmetry_group) == Py_None);
    if (__pyx_t_7) {
 1156:                 #print_(child_empty + "to main thread, rank: %i" % rank, self.logfile)
 1157:                 if all_symmetries_found and size > 1:
      /* "water_algorithm_cython.pyx":1157
 *             if parent_self_symmetry_group is None:
 *                 #print_(child_empty + "to main thread, rank: %i" % rank, self.logfile)
 *                 if all_symmetries_found and size > 1:             # <<<<<<<<<<<<<<
 *                     water_orientations = stack(water_orientations, comm.scatter(split_list(new_water_orientations.base,  size),  root = 0))
 *                 else:
 */
      if (__pyx_v_all_symmetries_found) {
        __pyx_t_7 = (size > 1);
        __pyx_t_10 = __pyx_t_7;
      } else {
        __pyx_t_10 = __pyx_v_all_symmetries_found;
      }
      if (__pyx_t_10) {
 1158:                     water_orientations = stack(water_orientations, comm.scatter(split_list(new_water_orientations.base,  size),  root = 0))
        /* "water_algorithm_cython.pyx":1158
 *                 #print_(child_empty + "to main thread, rank: %i" % rank, self.logfile)
 *                 if all_symmetries_found and size > 1:
 *                     water_orientations = stack(water_orientations, comm.scatter(split_list(new_water_orientations.base,  size),  root = 0))             # <<<<<<<<<<<<<<
 *                 else:
 *                     water_orientations = stack(water_orientations, new_water_orientations)
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__scatter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__split_list); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyInt_FromLong(size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_5 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
        __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
        if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_12), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
        if (unlikely(!__pyx_t_13.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_14 = __pyx_f_22water_algorithm_cython_stack(__pyx_v_water_orientations, __pyx_t_13); if (unlikely(!__pyx_t_14.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
        __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
        __pyx_v_water_orientations = __pyx_t_14;
        __pyx_t_14.memview = NULL;
        __pyx_t_14.data = NULL;
        goto __pyx_L17;
      }
      /*else*/ {
 1159:                 else:
 1160:                     water_orientations = stack(water_orientations, new_water_orientations)
        /* "water_algorithm_cython.pyx":1160
 *                     water_orientations = stack(water_orientations, comm.scatter(split_list(new_water_orientations.base,  size),  root = 0))
 *                 else:
 *                     water_orientations = stack(water_orientations, new_water_orientations)             # <<<<<<<<<<<<<<
 *             else:
 *                 #print_(child_empty + "to parent, rank: %i" % rank, self.logfile)
 */
        __pyx_t_14 = __pyx_f_22water_algorithm_cython_stack(__pyx_v_water_orientations, __pyx_v_new_water_orientations); if (unlikely(!__pyx_t_14.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
        __pyx_v_water_orientations = __pyx_t_14;
        __pyx_t_14.memview = NULL;
        __pyx_t_14.data = NULL;
      }
      __pyx_L17:;
      goto __pyx_L16;
    }
    /*else*/ {
 1161:             else:
 1162:                 #print_(child_empty + "to parent, rank: %i" % rank, self.logfile)
 1163:                 parent_self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]> stack(parent_self_symmetry_group.water_orientations, new_water_orientations).base
      /* "water_algorithm_cython.pyx":1163
 *             else:
 *                 #print_(child_empty + "to parent, rank: %i" % rank, self.logfile)
 *                 parent_self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]> stack(parent_self_symmetry_group.water_orientations, new_water_orientations).base             # <<<<<<<<<<<<<<
 *             #print_(child_empty + "%s" % new_water_orientations.base, self.logfile)
 *             self_symmetry_group.water_orientations = None #np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)
 */
      __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_parent_self_symmetry_group->water_orientations));
      if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = __pyx_f_22water_algorithm_cython_stack(__pyx_t_15, __pyx_v_new_water_orientations); if (unlikely(!__pyx_t_14.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
      __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_t_14, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_t_1)));
      __Pyx_GIVEREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_v_parent_self_symmetry_group->water_orientations);
      __Pyx_DECREF(((PyObject *)__pyx_v_parent_self_symmetry_group->water_orientations));
      __pyx_v_parent_self_symmetry_group->water_orientations = ((PyArrayObject *)__pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __pyx_L16:;
 1164:             #print_(child_empty + "%s" % new_water_orientations.base, self.logfile)
 1165:             self_symmetry_group.water_orientations = None #np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":1165
 *                 parent_self_symmetry_group.water_orientations = <np.ndarray[DTYPE2_t, ndim=2]> stack(parent_self_symmetry_group.water_orientations, new_water_orientations).base
 *             #print_(child_empty + "%s" % new_water_orientations.base, self.logfile)
 *             self_symmetry_group.water_orientations = None #np.ndarray((0, water_orientations.shape[1]), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self_symmetry_group->water_orientations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
    __pyx_v_self_symmetry_group->water_orientations = ((PyArrayObject *)Py_None);
 1166: 
 1167: 
 1168: 
 1169: 
 1170:             # Group the new child groups to main ResultGroup
 1171:             self.result_group = main_result_group
    /* "water_algorithm_cython.pyx":1171
 * 
 *             # Group the new child groups to main ResultGroup
 *             self.result_group = main_result_group             # <<<<<<<<<<<<<<
 *             Q = len(child_self_symmetry_groups)
 *             for j from 0 <= j < Q:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_main_result_group));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_main_result_group));
    __Pyx_GOTREF(__pyx_v_self->result_group);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
    __pyx_v_self->result_group = __pyx_v_main_result_group;
 1172:             Q = len(child_self_symmetry_groups)
    /* "water_algorithm_cython.pyx":1172
 *             # Group the new child groups to main ResultGroup
 *             self.result_group = main_result_group
 *             Q = len(child_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *             for j from 0 <= j < Q:
 *                 child_self_symmetry_group = <SelfSymmetryGroup> child_self_symmetry_groups[j]
 */
    __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_child_self_symmetry_groups)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_Q = __pyx_t_2;
 1173:             for j from 0 <= j < Q:
    /* "water_algorithm_cython.pyx":1173
 *             self.result_group = main_result_group
 *             Q = len(child_self_symmetry_groups)
 *             for j from 0 <= j < Q:             # <<<<<<<<<<<<<<
 *                 child_self_symmetry_group = <SelfSymmetryGroup> child_self_symmetry_groups[j]
 *                 child_self_symmetry_group.water_orientations = self.remove_symmetric_results(child_self_symmetry_group.water_orientations, molecule_no, tested_symmetry_operations, result_group_count, None, False, None, child_self_symmetry_group, 1, False)
 */
    __pyx_t_9 = __pyx_v_Q;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_9; __pyx_v_j++) {
 1174:                 child_self_symmetry_group = <SelfSymmetryGroup> child_self_symmetry_groups[j]
      /* "water_algorithm_cython.pyx":1174
 *             Q = len(child_self_symmetry_groups)
 *             for j from 0 <= j < Q:
 *                 child_self_symmetry_group = <SelfSymmetryGroup> child_self_symmetry_groups[j]             # <<<<<<<<<<<<<<
 *                 child_self_symmetry_group.water_orientations = self.remove_symmetric_results(child_self_symmetry_group.water_orientations, molecule_no, tested_symmetry_operations, result_group_count, None, False, None, child_self_symmetry_group, 1, False)
 *                 self.result_group.clear_wos_from_level(1)
 */
      __pyx_t_1 = PyList_GET_ITEM(__pyx_v_child_self_symmetry_groups, __pyx_v_j);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF(((PyObject *)__pyx_v_child_self_symmetry_group));
      __pyx_v_child_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_1);
      __pyx_t_1 = 0;
 1175:                 child_self_symmetry_group.water_orientations = self.remove_symmetric_results(child_self_symmetry_group.water_orientations, molecule_no, tested_symmetry_operations, result_group_count, None, False, None, child_self_symmetry_group, 1, False)
      /* "water_algorithm_cython.pyx":1175
 *             for j from 0 <= j < Q:
 *                 child_self_symmetry_group = <SelfSymmetryGroup> child_self_symmetry_groups[j]
 *                 child_self_symmetry_group.water_orientations = self.remove_symmetric_results(child_self_symmetry_group.water_orientations, molecule_no, tested_symmetry_operations, result_group_count, None, False, None, child_self_symmetry_group, 1, False)             # <<<<<<<<<<<<<<
 *                 self.result_group.clear_wos_from_level(1)
 *             #    #bond_variables = get_bond_variables_3(child_self_symmetry_group.water_orientations[0],  self.nearest_neighbors_nos)
 */
      __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_child_self_symmetry_group->water_orientations));
      if (unlikely(!__pyx_t_16.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->remove_symmetric_results(__pyx_v_self, __pyx_t_16, __pyx_v_molecule_no, __pyx_v_tested_symmetry_operations, __pyx_v_result_group_count, ((PyObject*)Py_None), 0, ((PyObject*)Py_None), __pyx_v_child_self_symmetry_group, 1, 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
      __Pyx_GIVEREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_v_child_self_symmetry_group->water_orientations);
      __Pyx_DECREF(((PyObject *)__pyx_v_child_self_symmetry_group->water_orientations));
      __pyx_v_child_self_symmetry_group->water_orientations = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;
 1176:                 self.result_group.clear_wos_from_level(1)
      /* "water_algorithm_cython.pyx":1176
 *                 child_self_symmetry_group = <SelfSymmetryGroup> child_self_symmetry_groups[j]
 *                 child_self_symmetry_group.water_orientations = self.remove_symmetric_results(child_self_symmetry_group.water_orientations, molecule_no, tested_symmetry_operations, result_group_count, None, False, None, child_self_symmetry_group, 1, False)
 *                 self.result_group.clear_wos_from_level(1)             # <<<<<<<<<<<<<<
 *             #    #bond_variables = get_bond_variables_3(child_self_symmetry_group.water_orientations[0],  self.nearest_neighbors_nos)
 *             #    #rg = main_result_group.try_subgroups(bond_variables, 5)
 */
      ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->clear_wos_from_level(__pyx_v_self->result_group, 1);
    }
 1177:             #    #bond_variables = get_bond_variables_3(child_self_symmetry_group.water_orientations[0],  self.nearest_neighbors_nos)
 1178:             #    #rg = main_result_group.try_subgroups(bond_variables, 5)
 1179:             #    #rg.add_result(child_self_symmetry_group.water_orientations[0], None)
 1180:             self.result_group = group
    /* "water_algorithm_cython.pyx":1180
 *             #    #rg = main_result_group.try_subgroups(bond_variables, 5)
 *             #    #rg.add_result(child_self_symmetry_group.water_orientations[0], None)
 *             self.result_group = group             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_group));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_group));
    __Pyx_GOTREF(__pyx_v_self->result_group);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
    __pyx_v_self->result_group = __pyx_v_group;
    goto __pyx_L15;
  }
  /*else*/ {
 1181: 
 1182:         else:
 1183:             #print_(child_empty + "GROUP LEFT ALIVE", self.logfile)
 1184:             self_symmetry_group.symmetry_operations = leftover_symmetry_operations
    /* "water_algorithm_cython.pyx":1184
 *         else:
 *             #print_(child_empty + "GROUP LEFT ALIVE", self.logfile)
 *             self_symmetry_group.symmetry_operations = leftover_symmetry_operations             # <<<<<<<<<<<<<<
 *             self_symmetry_group.water_orientations = new_water_orientations.base
 *             new_self_symmetry_groups.append(self_symmetry_group)
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_leftover_symmetry_operations));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_leftover_symmetry_operations));
    __Pyx_GOTREF(__pyx_v_self_symmetry_group->symmetry_operations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self_symmetry_group->symmetry_operations));
    __pyx_v_self_symmetry_group->symmetry_operations = __pyx_v_leftover_symmetry_operations;
 1185:             self_symmetry_group.water_orientations = new_water_orientations.base
    /* "water_algorithm_cython.pyx":1185
 *             #print_(child_empty + "GROUP LEFT ALIVE", self.logfile)
 *             self_symmetry_group.symmetry_operations = leftover_symmetry_operations
 *             self_symmetry_group.water_orientations = new_water_orientations.base             # <<<<<<<<<<<<<<
 *             new_self_symmetry_groups.append(self_symmetry_group)
 * 
 */
    __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self_symmetry_group->water_orientations);
    __Pyx_DECREF(((PyObject *)__pyx_v_self_symmetry_group->water_orientations));
    __pyx_v_self_symmetry_group->water_orientations = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
 1186:             new_self_symmetry_groups.append(self_symmetry_group)
    /* "water_algorithm_cython.pyx":1186
 *             self_symmetry_group.symmetry_operations = leftover_symmetry_operations
 *             self_symmetry_group.water_orientations = new_water_orientations.base
 *             new_self_symmetry_groups.append(self_symmetry_group)             # <<<<<<<<<<<<<<
 * 
 *         return new_self_symmetry_groups, water_orientations
 */
    if (unlikely(((PyObject *)__pyx_v_new_self_symmetry_groups) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_new_self_symmetry_groups, ((PyObject *)__pyx_v_self_symmetry_group)); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L15:;
 1187: 
 1188:         return new_self_symmetry_groups, water_orientations
  /* "water_algorithm_cython.pyx":1188
 *             new_self_symmetry_groups.append(self_symmetry_group)
 * 
 *         return new_self_symmetry_groups, water_orientations             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_new_self_symmetry_groups));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_XDECREF(__pyx_t_12);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_self_symmetry_group", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_wos, 1);
  __Pyx_XDECREF(__pyx_v_tested_symmetry_operations);
  __Pyx_XDECREF(__pyx_v_leftover_symmetry_operations);
  __Pyx_XDECREF(__pyx_v_child_self_symmetry_groups);
  __Pyx_XDECREF((PyObject *)__pyx_v_group);
  __Pyx_XDECREF((PyObject *)__pyx_v_child_self_symmetry_group);
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_self_symmetry_group);
  __Pyx_XDECREF(__pyx_v_graph_invariants);
  __Pyx_XDECREF(__pyx_v_child_empty);
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1189: 
 1190: 
 1191: 
 1192:     cdef tuple handle_self_symmetry_groups(self, DTYPE2_t[:, ::1] water_orientations, unsigned char molecule_no, list self_symmetry_groups, list symmetry_operations, int result_group_count, bint save_self_symmetry_groups, bint all_symmetries_found, DTYPE_t [:, :, ::1] possible_combinations):
/* "water_algorithm_cython.pyx":1192
 * 
 * 
 *     cdef tuple handle_self_symmetry_groups(self, DTYPE2_t[:, ::1] water_orientations, unsigned char molecule_no, list self_symmetry_groups, list symmetry_operations, int result_group_count, bint save_self_symmetry_groups, bint all_symmetries_found, DTYPE_t [:, :, ::1] possible_combinations):             # <<<<<<<<<<<<<<
 * 
 *         cdef int i, j, k, l, m, discarded, N = len(self_symmetry_groups), M, L, O, P, total = 0, tested
 */

static PyObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_handle_self_symmetry_groups(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_water_orientations, unsigned char __pyx_v_molecule_no, PyObject *__pyx_v_self_symmetry_groups, PyObject *__pyx_v_symmetry_operations, int __pyx_v_result_group_count, int __pyx_v_save_self_symmetry_groups, int __pyx_v_all_symmetries_found, __Pyx_memviewslice __pyx_v_possible_combinations) {
  int __pyx_v_i;
  CYTHON_UNUSED int __pyx_v_discarded;
  int __pyx_v_N;
  CYTHON_UNUSED int __pyx_v_total;
  struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_self_symmetry_group = 0;
  struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_parent_self_symmetry_group = 0;
  PyObject *__pyx_v_new_self_symmetry_groups = 0;
  PyObject *__pyx_v_new_symmetry_operations = 0;
  __Pyx_memviewslice __pyx_v_nn = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_res = 0;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_result_group = 0;
  PyObject *__pyx_v_result = 0;
  int __pyx_v_o;
  int __pyx_v_E;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_self_symmetry_groups", 0);
  __PYX_INC_MEMVIEW(&__pyx_v_water_orientations, 1);
 1193: 
 1194:         cdef int i, j, k, l, m, discarded, N = len(self_symmetry_groups), M, L, O, P, total = 0, tested
  /* "water_algorithm_cython.pyx":1194
 *     cdef tuple handle_self_symmetry_groups(self, DTYPE2_t[:, ::1] water_orientations, unsigned char molecule_no, list self_symmetry_groups, list symmetry_operations, int result_group_count, bint save_self_symmetry_groups, bint all_symmetries_found, DTYPE_t [:, :, ::1] possible_combinations):
 * 
 *         cdef int i, j, k, l, m, discarded, N = len(self_symmetry_groups), M, L, O, P, total = 0, tested             # <<<<<<<<<<<<<<
 *         cdef SymmetryOperation symmetry_operation
 *         cdef SelfSymmetryGroup self_symmetry_group, child_self_symmetry_group, parent_self_symmetry_group
 */
  if (unlikely(((PyObject *)__pyx_v_self_symmetry_groups) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_self_symmetry_groups)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_N = __pyx_t_1;
  __pyx_v_total = 0;
 1195:         cdef SymmetryOperation symmetry_operation
 1196:         cdef SelfSymmetryGroup self_symmetry_group, child_self_symmetry_group, parent_self_symmetry_group
 1197:         cdef ResultGroup group
 1198: 
 1199:         cdef DTYPE_t are_symmetric, is_self_symmetric
 1200:         cdef bool add
 1201:         cdef list new_self_symmetry_groups = []
  /* "water_algorithm_cython.pyx":1201
 *         cdef DTYPE_t are_symmetric, is_self_symmetric
 *         cdef bool add
 *         cdef list new_self_symmetry_groups = []             # <<<<<<<<<<<<<<
 * 
 *         cdef list nchsg, all_child_self_symmetry_groups, all_new_children, new_cssgs
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_new_self_symmetry_groups = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
 1202: 
 1203:         cdef list nchsg, all_child_self_symmetry_groups, all_new_children, new_cssgs
 1204:         cdef list new_symmetry_operations
 1205:         cdef list tested_symmetry_operations, leftover_symmetry_operations, active_symmetry_operations
 1206:         cdef DTYPE_t[::1] nn = self.nearest_neighbors_nos[0, molecule_no]
  /* "water_algorithm_cython.pyx":1206
 *         cdef list new_symmetry_operations
 *         cdef list tested_symmetry_operations, leftover_symmetry_operations, active_symmetry_operations
 *         cdef DTYPE_t[::1] nn = self.nearest_neighbors_nos[0, molecule_no]             # <<<<<<<<<<<<<<
 *         if molecule_no == self.order[self.order.shape[0]-1]:
 *             save_self_symmetry_groups = False
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_molecule_no); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetItem(__pyx_t_2, ((PyObject *)__pyx_t_4)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_3);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_nn = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
 1207:         if molecule_no == self.order[self.order.shape[0]-1]:
  /* "water_algorithm_cython.pyx":1207
 *         cdef list tested_symmetry_operations, leftover_symmetry_operations, active_symmetry_operations
 *         cdef DTYPE_t[::1] nn = self.nearest_neighbors_nos[0, molecule_no]
 *         if molecule_no == self.order[self.order.shape[0]-1]:             # <<<<<<<<<<<<<<
 *             save_self_symmetry_groups = False
 * 
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_molecule_no); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = ((__pyx_v_self->order->dimensions[0]) - 1);
  __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->order), __pyx_t_6, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_7) {
 1208:             save_self_symmetry_groups = False
    /* "water_algorithm_cython.pyx":1208
 *         cdef DTYPE_t[::1] nn = self.nearest_neighbors_nos[0, molecule_no]
 *         if molecule_no == self.order[self.order.shape[0]-1]:
 *             save_self_symmetry_groups = False             # <<<<<<<<<<<<<<
 * 
 *         if rank == 0:
 */
    __pyx_v_save_self_symmetry_groups = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 1209: 
 1210:         if rank == 0:
  /* "water_algorithm_cython.pyx":1210
 *             save_self_symmetry_groups = False
 * 
 *         if rank == 0:             # <<<<<<<<<<<<<<
 *             new_symmetry_operations = remove_earlier_found(symmetry_operations)
 *         else:
 */
  __pyx_t_7 = (rank == 0);
  if (__pyx_t_7) {
 1211:             new_symmetry_operations = remove_earlier_found(symmetry_operations)
    /* "water_algorithm_cython.pyx":1211
 * 
 *         if rank == 0:
 *             new_symmetry_operations = remove_earlier_found(symmetry_operations)             # <<<<<<<<<<<<<<
 *         else:
 *             new_symmetry_operations = None
 */
    __pyx_t_2 = ((PyObject *)__pyx_f_10symmetries_25symmetry_operation_cython_remove_earlier_found(__pyx_v_symmetry_operations)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_new_symmetry_operations = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L4;
  }
  /*else*/ {
 1212:         else:
 1213:             new_symmetry_operations = None
    /* "water_algorithm_cython.pyx":1213
 *             new_symmetry_operations = remove_earlier_found(symmetry_operations)
 *         else:
 *             new_symmetry_operations = None             # <<<<<<<<<<<<<<
 *         new_symmetry_operations = comm.bcast(new_symmetry_operations, root = 0)
 *         s = time()
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_new_symmetry_operations = ((PyObject*)Py_None);
  }
  __pyx_L4:;
 1214:         new_symmetry_operations = comm.bcast(new_symmetry_operations, root = 0)
  /* "water_algorithm_cython.pyx":1214
 *         else:
 *             new_symmetry_operations = None
 *         new_symmetry_operations = comm.bcast(new_symmetry_operations, root = 0)             # <<<<<<<<<<<<<<
 *         s = time()
 *         cdef tuple res
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__bcast); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_new_symmetry_operations));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_new_symmetry_operations));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_new_symmetry_operations));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__root), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (!(likely(PyList_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_8)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_new_symmetry_operations));
  __pyx_v_new_symmetry_operations = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;
 1215:         s = time()
  /* "water_algorithm_cython.pyx":1215
 *             new_symmetry_operations = None
 *         new_symmetry_operations = comm.bcast(new_symmetry_operations, root = 0)
 *         s = time()             # <<<<<<<<<<<<<<
 *         cdef tuple res
 *         cdef ResultGroup result_group = self.result_group
 */
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_s = __pyx_t_3;
  __pyx_t_3 = 0;
 1216:         cdef tuple res
 1217:         cdef ResultGroup result_group = self.result_group
  /* "water_algorithm_cython.pyx":1217
 *         s = time()
 *         cdef tuple res
 *         cdef ResultGroup result_group = self.result_group             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < N:
 *             discarded = 0
 */
  __pyx_t_3 = ((PyObject *)__pyx_v_self->result_group);
  __Pyx_INCREF(__pyx_t_3);
  __pyx_v_result_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_3);
  __pyx_t_3 = 0;
 1218:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":1218
 *         cdef tuple res
 *         cdef ResultGroup result_group = self.result_group
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             discarded = 0
 *             if i % 1000 == 0:
 */
  __pyx_t_9 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
 1219:             discarded = 0
    /* "water_algorithm_cython.pyx":1219
 *         cdef ResultGroup result_group = self.result_group
 *         for i from 0 <= i < N:
 *             discarded = 0             # <<<<<<<<<<<<<<
 *             if i % 1000 == 0:
 *                 print_("-------------------------------------------------", self.logfile)
 */
    __pyx_v_discarded = 0;
 1220:             if i % 1000 == 0:
    /* "water_algorithm_cython.pyx":1220
 *         for i from 0 <= i < N:
 *             discarded = 0
 *             if i % 1000 == 0:             # <<<<<<<<<<<<<<
 *                 print_("-------------------------------------------------", self.logfile)
 *                 print_("Handling self symmetry group %i of %i " % (i+1, N), self.logfile)
 */
    __pyx_t_7 = (__Pyx_mod_long(__pyx_v_i, 1000) == 0);
    if (__pyx_t_7) {
 1221:                 print_("-------------------------------------------------", self.logfile)
      /* "water_algorithm_cython.pyx":1221
 *             discarded = 0
 *             if i % 1000 == 0:
 *                 print_("-------------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 *                 print_("Handling self symmetry group %i of %i " % (i+1, N), self.logfile)
 *                 print_("-------------------------------------------------", self.logfile)
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_89));
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_kp_s_89));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_89));
      __Pyx_INCREF(__pyx_v_self->logfile);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_self->logfile);
      __Pyx_GIVEREF(__pyx_v_self->logfile);
      __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1222:                 print_("Handling self symmetry group %i of %i " % (i+1, N), self.logfile)
      /* "water_algorithm_cython.pyx":1222
 *             if i % 1000 == 0:
 *                 print_("-------------------------------------------------", self.logfile)
 *                 print_("Handling self symmetry group %i of %i " % (i+1, N), self.logfile)             # <<<<<<<<<<<<<<
 *                 print_("-------------------------------------------------", self.logfile)
 * 
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyInt_FromLong((__pyx_v_i + 1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_8 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_90), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(__pyx_v_self->logfile);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
      __Pyx_GIVEREF(__pyx_v_self->logfile);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1223:                 print_("-------------------------------------------------", self.logfile)
      /* "water_algorithm_cython.pyx":1223
 *                 print_("-------------------------------------------------", self.logfile)
 *                 print_("Handling self symmetry group %i of %i " % (i+1, N), self.logfile)
 *                 print_("-------------------------------------------------", self.logfile)             # <<<<<<<<<<<<<<
 * 
 *             self_symmetry_group = <SelfSymmetryGroup>self_symmetry_groups[i]
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_kp_s_89));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_89));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_89));
      __Pyx_INCREF(__pyx_v_self->logfile);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
      __Pyx_GIVEREF(__pyx_v_self->logfile);
      __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L7;
    }
    __pyx_L7:;
 1224: 
 1225:             self_symmetry_group = <SelfSymmetryGroup>self_symmetry_groups[i]
    /* "water_algorithm_cython.pyx":1225
 *                 print_("-------------------------------------------------", self.logfile)
 * 
 *             self_symmetry_group = <SelfSymmetryGroup>self_symmetry_groups[i]             # <<<<<<<<<<<<<<
 *             res = self.handle_self_symmetry_group(self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations,  new_self_symmetry_groups, result_group_count, molecule_no, result_group, save_self_symmetry_groups, all_symmetries_found, nn, 0, possible_combinations)
 *             new_self_symmetry_groups = <list>res[0]
 */
    if (unlikely(((PyObject *)__pyx_v_self_symmetry_groups) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyList_GET_ITEM(__pyx_v_self_symmetry_groups, __pyx_v_i);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_XDECREF(((PyObject *)__pyx_v_self_symmetry_group));
    __pyx_v_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_4);
    __pyx_t_4 = 0;
 1226:             res = self.handle_self_symmetry_group(self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations,  new_self_symmetry_groups, result_group_count, molecule_no, result_group, save_self_symmetry_groups, all_symmetries_found, nn, 0, possible_combinations)
    /* "water_algorithm_cython.pyx":1226
 * 
 *             self_symmetry_group = <SelfSymmetryGroup>self_symmetry_groups[i]
 *             res = self.handle_self_symmetry_group(self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations,  new_self_symmetry_groups, result_group_count, molecule_no, result_group, save_self_symmetry_groups, all_symmetries_found, nn, 0, possible_combinations)             # <<<<<<<<<<<<<<
 *             new_self_symmetry_groups = <list>res[0]
 *             water_orientations = res[1]
 */
    __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->handle_self_symmetry_group(__pyx_v_self, __pyx_v_self_symmetry_group, __pyx_v_symmetry_operations, __pyx_v_new_symmetry_operations, __pyx_v_water_orientations, __pyx_v_new_self_symmetry_groups, __pyx_v_result_group_count, __pyx_v_molecule_no, __pyx_v_result_group, __pyx_v_save_self_symmetry_groups, __pyx_v_all_symmetries_found, __pyx_v_nn, 0, __pyx_v_possible_combinations)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF(((PyObject *)__pyx_v_res));
    __pyx_v_res = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 1227:             new_self_symmetry_groups = <list>res[0]
    /* "water_algorithm_cython.pyx":1227
 *             self_symmetry_group = <SelfSymmetryGroup>self_symmetry_groups[i]
 *             res = self.handle_self_symmetry_group(self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations,  new_self_symmetry_groups, result_group_count, molecule_no, result_group, save_self_symmetry_groups, all_symmetries_found, nn, 0, possible_combinations)
 *             new_self_symmetry_groups = <list>res[0]             # <<<<<<<<<<<<<<
 *             water_orientations = res[1]
 * 
 */
    if (unlikely(((PyObject *)__pyx_v_res) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = PyTuple_GET_ITEM(__pyx_v_res, 0);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
    __pyx_v_new_self_symmetry_groups = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 1228:             water_orientations = res[1]
    /* "water_algorithm_cython.pyx":1228
 *             res = self.handle_self_symmetry_group(self_symmetry_group, symmetry_operations, new_symmetry_operations, water_orientations,  new_self_symmetry_groups, result_group_count, molecule_no, result_group, save_self_symmetry_groups, all_symmetries_found, nn, 0, possible_combinations)
 *             new_self_symmetry_groups = <list>res[0]
 *             water_orientations = res[1]             # <<<<<<<<<<<<<<
 * 
 *         self.self_symmetry_time += time() - s
 */
    if (unlikely(((PyObject *)__pyx_v_res) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(PyTuple_GET_ITEM(__pyx_v_res, 1));
    if (unlikely(!__pyx_t_10.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
    __pyx_v_water_orientations = __pyx_t_10;
    __pyx_t_10.memview = NULL;
    __pyx_t_10.data = NULL;
  }
 1229: 
 1230:         self.self_symmetry_time += time() - s
  /* "water_algorithm_cython.pyx":1230
 *             water_orientations = res[1]
 * 
 *         self.self_symmetry_time += time() - s             # <<<<<<<<<<<<<<
 *         self.result_group.clear_wos_from_level(1)# = ResultGroup(list(self.graph_invariants),  0)
 *         #print "Total %i water orientations in self symmetry_groups" % (total + len(new_self_symmetry_groups))
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__self_symmetry_time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__self_symmetry_time, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1231:         self.result_group.clear_wos_from_level(1)# = ResultGroup(list(self.graph_invariants),  0)
  /* "water_algorithm_cython.pyx":1231
 * 
 *         self.self_symmetry_time += time() - s
 *         self.result_group.clear_wos_from_level(1)# = ResultGroup(list(self.graph_invariants),  0)             # <<<<<<<<<<<<<<
 *         #print "Total %i water orientations in self symmetry_groups" % (total + len(new_self_symmetry_groups))
 *         cdef list result = []
 */
  ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->clear_wos_from_level(__pyx_v_self->result_group, 1);
 1232:         #print "Total %i water orientations in self symmetry_groups" % (total + len(new_self_symmetry_groups))
 1233:         cdef list result = []
  /* "water_algorithm_cython.pyx":1233
 *         self.result_group.clear_wos_from_level(1)# = ResultGroup(list(self.graph_invariants),  0)
 *         #print "Total %i water orientations in self symmetry_groups" % (total + len(new_self_symmetry_groups))
 *         cdef list result = []             # <<<<<<<<<<<<<<
 *         cdef int o, E = len(new_self_symmetry_groups)
 *         for o from 0 <= o < E:
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_result = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
 1234:         cdef int o, E = len(new_self_symmetry_groups)
  /* "water_algorithm_cython.pyx":1234
 *         #print "Total %i water orientations in self symmetry_groups" % (total + len(new_self_symmetry_groups))
 *         cdef list result = []
 *         cdef int o, E = len(new_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *         for o from 0 <= o < E:
 *             self_symmetry_group = <SelfSymmetryGroup>new_self_symmetry_groups[o]
 */
  if (unlikely(((PyObject *)__pyx_v_new_self_symmetry_groups) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_new_self_symmetry_groups)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_E = __pyx_t_1;
 1235:         for o from 0 <= o < E:
  /* "water_algorithm_cython.pyx":1235
 *         cdef list result = []
 *         cdef int o, E = len(new_self_symmetry_groups)
 *         for o from 0 <= o < E:             # <<<<<<<<<<<<<<
 *             self_symmetry_group = <SelfSymmetryGroup>new_self_symmetry_groups[o]
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
 */
  __pyx_t_9 = __pyx_v_E;
  for (__pyx_v_o = 0; __pyx_v_o < __pyx_t_9; __pyx_v_o++) {
 1236:             self_symmetry_group = <SelfSymmetryGroup>new_self_symmetry_groups[o]
    /* "water_algorithm_cython.pyx":1236
 *         cdef int o, E = len(new_self_symmetry_groups)
 *         for o from 0 <= o < E:
 *             self_symmetry_group = <SelfSymmetryGroup>new_self_symmetry_groups[o]             # <<<<<<<<<<<<<<
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
 *             if parent_self_symmetry_group is None and not self_symmetry_group.finalized:
 */
    if (unlikely(((PyObject *)__pyx_v_new_self_symmetry_groups) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = PyList_GET_ITEM(__pyx_v_new_self_symmetry_groups, __pyx_v_o);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF(((PyObject *)__pyx_v_self_symmetry_group));
    __pyx_v_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_3);
    __pyx_t_3 = 0;
 1237:             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
    /* "water_algorithm_cython.pyx":1237
 *         for o from 0 <= o < E:
 *             self_symmetry_group = <SelfSymmetryGroup>new_self_symmetry_groups[o]
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()             # <<<<<<<<<<<<<<
 *             if parent_self_symmetry_group is None and not self_symmetry_group.finalized:
 *                 result.append(self_symmetry_group)
 */
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_v_self_symmetry_group->__pyx_vtab)->get_active_parent_self_symmetry_group(__pyx_v_self_symmetry_group)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF(((PyObject *)__pyx_v_parent_self_symmetry_group));
    __pyx_v_parent_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_3);
    __pyx_t_3 = 0;
 1238:             if parent_self_symmetry_group is None and not self_symmetry_group.finalized:
    /* "water_algorithm_cython.pyx":1238
 *             self_symmetry_group = <SelfSymmetryGroup>new_self_symmetry_groups[o]
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
 *             if parent_self_symmetry_group is None and not self_symmetry_group.finalized:             # <<<<<<<<<<<<<<
 *                 result.append(self_symmetry_group)
 * 
 */
    __pyx_t_7 = (((PyObject *)__pyx_v_parent_self_symmetry_group) == Py_None);
    if (__pyx_t_7) {
      __pyx_t_11 = (!__pyx_v_self_symmetry_group->finalized);
      __pyx_t_12 = __pyx_t_11;
    } else {
      __pyx_t_12 = __pyx_t_7;
    }
    if (__pyx_t_12) {
 1239:                 result.append(self_symmetry_group)
      /* "water_algorithm_cython.pyx":1239
 *             parent_self_symmetry_group = self_symmetry_group.get_active_parent_self_symmetry_group()
 *             if parent_self_symmetry_group is None and not self_symmetry_group.finalized:
 *                 result.append(self_symmetry_group)             # <<<<<<<<<<<<<<
 * 
 *         #if size > 0:
 */
      __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_result, ((PyObject *)__pyx_v_self_symmetry_group)); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L10;
    }
    __pyx_L10:;
  }
 1240: 
 1241:         #if size > 0:
 1242:         #    print "MERGING"
 1243:         #    result = merge(comm.allgather(result))
 1244:         return result, water_orientations.base
  /* "water_algorithm_cython.pyx":1244
 *         #    print "MERGING"
 *         #    result = merge(comm.allgather(result))
 *         return result, water_orientations.base             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_result));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_result));
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __Pyx_XDECREF(__pyx_t_8);
  __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.handle_self_symmetry_groups", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_self_symmetry_group);
  __Pyx_XDECREF((PyObject *)__pyx_v_parent_self_symmetry_group);
  __Pyx_XDECREF(__pyx_v_new_self_symmetry_groups);
  __Pyx_XDECREF(__pyx_v_new_symmetry_operations);
  __PYX_XDEC_MEMVIEW(&__pyx_v_nn, 1);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_res);
  __Pyx_XDECREF((PyObject *)__pyx_v_result_group);
  __Pyx_XDECREF(__pyx_v_result);
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1245: 
 1246: 
 1247: 
 1248: 
 1249: 
 1250: 
 1251:     cdef np.ndarray[DTYPE2_t, ndim=2] remove_symmetric_results(self, DTYPE2_t[:, ::1] water_orientations, unsigned char molecule_no, list symmetry_operations, int result_group_level, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, int depth_limit, bint scatter):
/* "water_algorithm_cython.pyx":1251
 * 
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] remove_symmetric_results(self, DTYPE2_t[:, ::1] water_orientations, unsigned char molecule_no, list symmetry_operations, int result_group_level, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, int depth_limit, bint scatter):             # <<<<<<<<<<<<<<
 * 
 *         #print "Performing symmetry check for %i geometries and %i symmetry operations" % (length_before, len(symmetry_operations))
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_remove_symmetric_results(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_water_orientations, unsigned char __pyx_v_molecule_no, PyObject *__pyx_v_symmetry_operations, int __pyx_v_result_group_level, PyObject *__pyx_v_self_symmetry_groups, int __pyx_v_save_self_symmetry_groups, PyObject *__pyx_v_pending_self_symmetry_operations, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_parent_self_symmetry_group, int __pyx_v_depth_limit, int __pyx_v_scatter) {
  CYTHON_UNUSED int __pyx_v_length_before;
  PyObject *__pyx_v_new_self_symmetry_groups = 0;
  PyObject *__pyx_v_groups = 0;
  CYTHON_UNUSED int __pyx_v_depth;
  int __pyx_v_O;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_group = 0;
  struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_self_symmetry_group = 0;
  int __pyx_v_l;
  int __pyx_v_total_loaded;
  int __pyx_v_N;
  int __pyx_v_count;
  int __pyx_v_P;
  int __pyx_v_j;
  PyArrayObject *__pyx_v_result = 0;
  __Pyx_memviewslice __pyx_v_new_water_orientations = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
  __Pyx_Buffer __pyx_pybuffer_result;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_symmetric_results", 0);
  __pyx_pybuffer_result.pybuffer.buf = NULL;
  __pyx_pybuffer_result.refcount = 0;
  __pyx_pybuffernd_result.data = NULL;
  __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
 1252: 
 1253:         #print "Performing symmetry check for %i geometries and %i symmetry operations" % (length_before, len(symmetry_operations))
 1254:         #if len(symmetry_operations) == 0:
 1255:         #    return water_orientations.base
 1256:         cdef int length_before = water_orientations.shape[0]
  /* "water_algorithm_cython.pyx":1256
 *         #if len(symmetry_operations) == 0:
 *         #    return water_orientations.base
 *         cdef int length_before = water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *         cdef list new_self_symmetry_groups = []
 *         # Split the water orientations for the processors
 */
  __pyx_v_length_before = (__pyx_v_water_orientations.shape[0]);
 1257:         cdef list new_self_symmetry_groups = []
  /* "water_algorithm_cython.pyx":1257
 *         #    return water_orientations.base
 *         cdef int length_before = water_orientations.shape[0]
 *         cdef list new_self_symmetry_groups = []             # <<<<<<<<<<<<<<
 *         # Split the water orientations for the processors
 *         cdef list groups
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new_self_symmetry_groups = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 1258:         # Split the water orientations for the processors
 1259:         cdef list groups
 1260:         cdef int depth
 1261:         cdef int O = water_orientations.shape[0]
  /* "water_algorithm_cython.pyx":1261
 *         cdef list groups
 *         cdef int depth
 *         cdef int O = water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *         groups, depth = self.do_initial_grouping(<np.ndarray[DTYPE2_t, ndim=2]>water_orientations.base, depth_limit, scatter)
 *         cdef ResultGroup group
 */
  __pyx_v_O = (__pyx_v_water_orientations.shape[0]);
 1262:         groups, depth = self.do_initial_grouping(<np.ndarray[DTYPE2_t, ndim=2]>water_orientations.base, depth_limit, scatter)
  /* "water_algorithm_cython.pyx":1262
 *         cdef int depth
 *         cdef int O = water_orientations.shape[0]
 *         groups, depth = self.do_initial_grouping(<np.ndarray[DTYPE2_t, ndim=2]>water_orientations.base, depth_limit, scatter)             # <<<<<<<<<<<<<<
 *         cdef ResultGroup group
 *         cdef SelfSymmetryGroup self_symmetry_group
 */
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->do_initial_grouping(__pyx_v_self, ((PyArrayObject *)__pyx_t_2), __pyx_v_depth_limit, __pyx_v_scatter)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyTuple_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else if (1) {
    __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_groups = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_depth = __pyx_t_6;
 1263:         cdef ResultGroup group
 1264:         cdef SelfSymmetryGroup self_symmetry_group
 1265:         cdef int i, l, loaded, total_loaded = 0
  /* "water_algorithm_cython.pyx":1265
 *         cdef ResultGroup group
 *         cdef SelfSymmetryGroup self_symmetry_group
 *         cdef int i, l, loaded, total_loaded = 0             # <<<<<<<<<<<<<<
 *         cdef int N = len(groups)
 *         cdef int M, count = 0
 */
  __pyx_v_total_loaded = 0;
 1266:         cdef int N = len(groups)
  /* "water_algorithm_cython.pyx":1266
 *         cdef SelfSymmetryGroup self_symmetry_group
 *         cdef int i, l, loaded, total_loaded = 0
 *         cdef int N = len(groups)             # <<<<<<<<<<<<<<
 *         cdef int M, count = 0
 *         cdef int P, j
 */
  if (unlikely(((PyObject *)__pyx_v_groups) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_groups)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_N = __pyx_t_7;
 1267:         cdef int M, count = 0
  /* "water_algorithm_cython.pyx":1267
 *         cdef int i, l, loaded, total_loaded = 0
 *         cdef int N = len(groups)
 *         cdef int M, count = 0             # <<<<<<<<<<<<<<
 *         cdef int P, j
 *         cdef np.ndarray[DTYPE2_t, ndim=2] result
 */
  __pyx_v_count = 0;
 1268:         cdef int P, j
 1269:         cdef np.ndarray[DTYPE2_t, ndim=2] result
 1270:         cdef DTYPE2_t[:, ::1] new_water_orientations = np.ndarray((O, water_orientations.shape[1]), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":1270
 *         cdef int P, j
 *         cdef np.ndarray[DTYPE2_t, ndim=2] result
 *         cdef DTYPE2_t[:, ::1] new_water_orientations = np.ndarray((O, water_orientations.shape[1]), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         #cdef list merged_groups = []
 *         # Finally do the symmetry checking
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_O); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_water_orientations.shape[1])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_1);
  if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_new_water_orientations = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 1271:         #cdef list merged_groups = []
 1272:         # Finally do the symmetry checking
 1273:         #print "Processor number %i handles %i result groups" % (rank, len(groups))
 1274:         for l from 0 <= l < N:
  /* "water_algorithm_cython.pyx":1274
 *         # Finally do the symmetry checking
 *         #print "Processor number %i handles %i result groups" % (rank, len(groups))
 *         for l from 0 <= l < N:             # <<<<<<<<<<<<<<
 *             group = <ResultGroup>groups[l]
 *             if group.get_wos() is not None:
 */
  __pyx_t_6 = __pyx_v_N;
  for (__pyx_v_l = 0; __pyx_v_l < __pyx_t_6; __pyx_v_l++) {
 1275:             group = <ResultGroup>groups[l]
    /* "water_algorithm_cython.pyx":1275
 *         #print "Processor number %i handles %i result groups" % (rank, len(groups))
 *         for l from 0 <= l < N:
 *             group = <ResultGroup>groups[l]             # <<<<<<<<<<<<<<
 *             if group.get_wos() is not None:
 *                 self.symmetries_loaded = 0
 */
    if (unlikely(((PyObject *)__pyx_v_groups) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_1 = PyList_GET_ITEM(__pyx_v_groups, __pyx_v_l);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(((PyObject *)__pyx_v_group));
    __pyx_v_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_1);
    __pyx_t_1 = 0;
 1276:             if group.get_wos() is not None:
    /* "water_algorithm_cython.pyx":1276
 *         for l from 0 <= l < N:
 *             group = <ResultGroup>groups[l]
 *             if group.get_wos() is not None:             # <<<<<<<<<<<<<<
 *                 self.symmetries_loaded = 0
 *                 new_water_orientations = self.remove_symmetries_for_single_group(group, new_water_orientations, result_group_level, molecule_no, symmetry_operations, new_self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, &count)
 */
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->get_wos(__pyx_v_group)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = (__pyx_t_1 != Py_None);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_9) {
 1277:                 self.symmetries_loaded = 0
      /* "water_algorithm_cython.pyx":1277
 *             group = <ResultGroup>groups[l]
 *             if group.get_wos() is not None:
 *                 self.symmetries_loaded = 0             # <<<<<<<<<<<<<<
 *                 new_water_orientations = self.remove_symmetries_for_single_group(group, new_water_orientations, result_group_level, molecule_no, symmetry_operations, new_self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, &count)
 *                 total_loaded += self.symmetries_loaded
 */
      __pyx_v_self->symmetries_loaded = 0;
 1278:                 new_water_orientations = self.remove_symmetries_for_single_group(group, new_water_orientations, result_group_level, molecule_no, symmetry_operations, new_self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, &count)
      /* "water_algorithm_cython.pyx":1278
 *             if group.get_wos() is not None:
 *                 self.symmetries_loaded = 0
 *                 new_water_orientations = self.remove_symmetries_for_single_group(group, new_water_orientations, result_group_level, molecule_no, symmetry_operations, new_self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, &count)             # <<<<<<<<<<<<<<
 *                 total_loaded += self.symmetries_loaded
 *                 #merged_groups.append(group)
 */
      __pyx_t_10 = __pyx_f_22water_algorithm_cython_14WaterAlgorithm_remove_symmetries_for_single_group(__pyx_v_self, __pyx_v_group, __pyx_v_new_water_orientations, __pyx_v_result_group_level, __pyx_v_molecule_no, __pyx_v_symmetry_operations, __pyx_v_new_self_symmetry_groups, __pyx_v_save_self_symmetry_groups, __pyx_v_pending_self_symmetry_operations, __pyx_v_parent_self_symmetry_group, (&__pyx_v_count)); if (unlikely(!__pyx_t_10.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
      __pyx_v_new_water_orientations = __pyx_t_10;
      __pyx_t_10.memview = NULL;
      __pyx_t_10.data = NULL;
 1279:                 total_loaded += self.symmetries_loaded
      /* "water_algorithm_cython.pyx":1279
 *                 self.symmetries_loaded = 0
 *                 new_water_orientations = self.remove_symmetries_for_single_group(group, new_water_orientations, result_group_level, molecule_no, symmetry_operations, new_self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, &count)
 *                 total_loaded += self.symmetries_loaded             # <<<<<<<<<<<<<<
 *                 #merged_groups.append(group)
 * 
 */
      __pyx_v_total_loaded = (__pyx_v_total_loaded + __pyx_v_self->symmetries_loaded);
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
 1280:                 #merged_groups.append(group)
 1281: 
 1282: 
 1283: 
 1284: 
 1285:         if scatter:
  /* "water_algorithm_cython.pyx":1285
 * 
 * 
 *         if scatter:             # <<<<<<<<<<<<<<
 *             new_self_symmetry_groups = merge(comm.allgather(new_self_symmetry_groups))
 *             result =  merge_water_orientations(comm.allgather(new_water_orientations.base[:count]))
 */
  if (__pyx_v_scatter) {
 1286:             new_self_symmetry_groups = merge(comm.allgather(new_self_symmetry_groups))
    /* "water_algorithm_cython.pyx":1286
 * 
 *         if scatter:
 *             new_self_symmetry_groups = merge(comm.allgather(new_self_symmetry_groups))             # <<<<<<<<<<<<<<
 *             result =  merge_water_orientations(comm.allgather(new_water_orientations.base[:count]))
 *             #print "gathered %i, %i" % (new_water_orientations.shape[0], rank)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__merge); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__allgather); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_new_self_symmetry_groups));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
    __pyx_v_new_self_symmetry_groups = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 1287:             result =  merge_water_orientations(comm.allgather(new_water_orientations.base[:count]))
    /* "water_algorithm_cython.pyx":1287
 *         if scatter:
 *             new_self_symmetry_groups = merge(comm.allgather(new_self_symmetry_groups))
 *             result =  merge_water_orientations(comm.allgather(new_water_orientations.base[:count]))             # <<<<<<<<<<<<<<
 *             #print "gathered %i, %i" % (new_water_orientations.shape[0], rank)
 *         else:
 */
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_67); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_22water_algorithm_cython_comm), __pyx_n_s__allgather); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, __pyx_v_count, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
      }
      __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_11 = 0;
    __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L8;
  }
  /*else*/ {
 1288:             #print "gathered %i, %i" % (new_water_orientations.shape[0], rank)
 1289:         else:
 1290:             result = new_water_orientations.base[:count]
    /* "water_algorithm_cython.pyx":1290
 *             #print "gathered %i, %i" % (new_water_orientations.shape[0], rank)
 *         else:
 *             result = new_water_orientations.base[:count]             # <<<<<<<<<<<<<<
 * 
 *         if self_symmetry_groups is not None:
 */
    __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_new_water_orientations, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, __pyx_v_count, NULL, NULL, NULL, 0, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
        }
      }
      __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_result.diminfo[1].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_result.diminfo[1].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_11 = 0;
    __pyx_v_result = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L8:;
 1291: 
 1292:         if self_symmetry_groups is not None:
  /* "water_algorithm_cython.pyx":1292
 *             result = new_water_orientations.base[:count]
 * 
 *         if self_symmetry_groups is not None:             # <<<<<<<<<<<<<<
 *             P = len(new_self_symmetry_groups)
 *             for j from 0 <= j < P:
 */
  __pyx_t_9 = (__pyx_v_self_symmetry_groups != ((PyObject*)Py_None));
  if (__pyx_t_9) {
 1293:             P = len(new_self_symmetry_groups)
    /* "water_algorithm_cython.pyx":1293
 * 
 *         if self_symmetry_groups is not None:
 *             P = len(new_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *             for j from 0 <= j < P:
 *                 self_symmetry_group = <SelfSymmetryGroup> new_self_symmetry_groups[j]
 */
    if (unlikely(((PyObject *)__pyx_v_new_self_symmetry_groups) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_new_self_symmetry_groups)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_P = __pyx_t_7;
 1294:             for j from 0 <= j < P:
    /* "water_algorithm_cython.pyx":1294
 *         if self_symmetry_groups is not None:
 *             P = len(new_self_symmetry_groups)
 *             for j from 0 <= j < P:             # <<<<<<<<<<<<<<
 *                 self_symmetry_group = <SelfSymmetryGroup> new_self_symmetry_groups[j]
 *                 self_symmetry_group.parent_self_symmetry_group = parent_self_symmetry_group
 */
    __pyx_t_6 = __pyx_v_P;
    for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_6; __pyx_v_j++) {
 1295:                 self_symmetry_group = <SelfSymmetryGroup> new_self_symmetry_groups[j]
      /* "water_algorithm_cython.pyx":1295
 *             P = len(new_self_symmetry_groups)
 *             for j from 0 <= j < P:
 *                 self_symmetry_group = <SelfSymmetryGroup> new_self_symmetry_groups[j]             # <<<<<<<<<<<<<<
 *                 self_symmetry_group.parent_self_symmetry_group = parent_self_symmetry_group
 *             self_symmetry_groups.extend(new_self_symmetry_groups)
 */
      if (unlikely(((PyObject *)__pyx_v_new_self_symmetry_groups) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_1 = PyList_GET_ITEM(__pyx_v_new_self_symmetry_groups, __pyx_v_j);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF(((PyObject *)__pyx_v_self_symmetry_group));
      __pyx_v_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_1);
      __pyx_t_1 = 0;
 1296:                 self_symmetry_group.parent_self_symmetry_group = parent_self_symmetry_group
      /* "water_algorithm_cython.pyx":1296
 *             for j from 0 <= j < P:
 *                 self_symmetry_group = <SelfSymmetryGroup> new_self_symmetry_groups[j]
 *                 self_symmetry_group.parent_self_symmetry_group = parent_self_symmetry_group             # <<<<<<<<<<<<<<
 *             self_symmetry_groups.extend(new_self_symmetry_groups)
 * 
 */
      __Pyx_INCREF(((PyObject *)__pyx_v_parent_self_symmetry_group));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_parent_self_symmetry_group));
      __Pyx_GOTREF(__pyx_v_self_symmetry_group->parent_self_symmetry_group);
      __Pyx_DECREF(((PyObject *)__pyx_v_self_symmetry_group->parent_self_symmetry_group));
      __pyx_v_self_symmetry_group->parent_self_symmetry_group = __pyx_v_parent_self_symmetry_group;
    }
 1297:             self_symmetry_groups.extend(new_self_symmetry_groups)
    /* "water_algorithm_cython.pyx":1297
 *                 self_symmetry_group = <SelfSymmetryGroup> new_self_symmetry_groups[j]
 *                 self_symmetry_group.parent_self_symmetry_group = parent_self_symmetry_group
 *             self_symmetry_groups.extend(new_self_symmetry_groups)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self_symmetry_groups), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_new_self_symmetry_groups));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;
 1298: 
 1299: 
 1300:         #print_("%i self symmetry groups, rank: %i" % (len(self_symmetry_groups), rank), self.logfile)
 1301: 
 1302:         #print "  -Loaded symmetries during process for %i wos" % total_loaded
 1303:         #print "  -Removed  %i geometries due to symmetry" % (length_before - new_water_orientations.shape[0])
 1304:         #print "  -Finally %i geometries" % result.shape[0]
 1305: 
 1306:         return result
  /* "water_algorithm_cython.pyx":1306
 *         #print "  -Finally %i geometries" % result.shape[0]
 * 
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     cdef inline DTYPE2_t[:, ::1] remove_symmetries_for_single_group(self, ResultGroup group, DTYPE2_t[:, ::1] new_water_orientations, int result_group_level, int molecule_no, list symmetry_operations, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, int *count):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyArrayObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.remove_symmetric_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_new_self_symmetry_groups);
  __Pyx_XDECREF(__pyx_v_groups);
  __Pyx_XDECREF((PyObject *)__pyx_v_group);
  __Pyx_XDECREF((PyObject *)__pyx_v_self_symmetry_group);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __PYX_XDEC_MEMVIEW(&__pyx_v_new_water_orientations, 1);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1307: 
 1308:     cdef inline DTYPE2_t[:, ::1] remove_symmetries_for_single_group(self, ResultGroup group, DTYPE2_t[:, ::1] new_water_orientations, int result_group_level, int molecule_no, list symmetry_operations, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, int *count):
/* "water_algorithm_cython.pyx":1308
 *         return result
 * 
 *     cdef inline DTYPE2_t[:, ::1] remove_symmetries_for_single_group(self, ResultGroup group, DTYPE2_t[:, ::1] new_water_orientations, int result_group_level, int molecule_no, list symmetry_operations, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, int *count):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] wo
 *         cdef np.ndarray[DTYPE2_t, ndim=2] wos = group.get_wos()
 */

static CYTHON_INLINE __Pyx_memviewslice __pyx_f_22water_algorithm_cython_14WaterAlgorithm_remove_symmetries_for_single_group(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_group, __Pyx_memviewslice __pyx_v_new_water_orientations, int __pyx_v_result_group_level, int __pyx_v_molecule_no, PyObject *__pyx_v_symmetry_operations, PyObject *__pyx_v_self_symmetry_groups, int __pyx_v_save_self_symmetry_groups, PyObject *__pyx_v_pending_self_symmetry_operations, struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_parent_self_symmetry_group, int *__pyx_v_count) {
  __Pyx_memviewslice __pyx_v_wo = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_wos = 0;
  int __pyx_v_i;
  int __pyx_v_M;
  __Pyx_memviewslice __pyx_v_bond_variables = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wos;
  __Pyx_Buffer __pyx_pybuffer_wos;
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_symmetries_for_single_group", 0);
  __pyx_pybuffer_wos.pybuffer.buf = NULL;
  __pyx_pybuffer_wos.refcount = 0;
  __pyx_pybuffernd_wos.data = NULL;
  __pyx_pybuffernd_wos.rcbuffer = &__pyx_pybuffer_wos;
 1309:         cdef DTYPE2_t[::1] wo
 1310:         cdef np.ndarray[DTYPE2_t, ndim=2] wos = group.get_wos()
  /* "water_algorithm_cython.pyx":1310
 *     cdef inline DTYPE2_t[:, ::1] remove_symmetries_for_single_group(self, ResultGroup group, DTYPE2_t[:, ::1] new_water_orientations, int result_group_level, int molecule_no, list symmetry_operations, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, int *count):
 *         cdef DTYPE2_t[::1] wo
 *         cdef np.ndarray[DTYPE2_t, ndim=2] wos = group.get_wos()             # <<<<<<<<<<<<<<
 *         cdef int i, M
 *         if wos is not None:
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_group->__pyx_vtab)->get_wos(__pyx_v_group)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wos.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_wos = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wos.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wos.diminfo[0].strides = __pyx_pybuffernd_wos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wos.diminfo[0].shape = __pyx_pybuffernd_wos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_wos.diminfo[1].strides = __pyx_pybuffernd_wos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_wos.diminfo[1].shape = __pyx_pybuffernd_wos.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_v_wos = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 1311:         cdef int i, M
 1312:         if wos is not None:
  /* "water_algorithm_cython.pyx":1312
 *         cdef np.ndarray[DTYPE2_t, ndim=2] wos = group.get_wos()
 *         cdef int i, M
 *         if wos is not None:             # <<<<<<<<<<<<<<
 *             M = wos.shape[0]
 *         else:
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_wos) != Py_None);
  if (__pyx_t_2) {
 1313:             M = wos.shape[0]
    /* "water_algorithm_cython.pyx":1313
 *         cdef int i, M
 *         if wos is not None:
 *             M = wos.shape[0]             # <<<<<<<<<<<<<<
 *         else:
 *             M = 0
 */
    __pyx_v_M = (__pyx_v_wos->dimensions[0]);
    goto __pyx_L3;
  }
  /*else*/ {
 1314:         else:
 1315:             M = 0
    /* "water_algorithm_cython.pyx":1315
 *             M = wos.shape[0]
 *         else:
 *             M = 0             # <<<<<<<<<<<<<<
 *         #print_("Processor %i: Current group has %i wos and invariant value is %i" % (rank, len(group.get_wos()), group.value), self.logfile)
 *         #print_(group.wos, self.logfile)
 */
    __pyx_v_M = 0;
  }
  __pyx_L3:;
 1316:         #print_("Processor %i: Current group has %i wos and invariant value is %i" % (rank, len(group.get_wos()), group.value), self.logfile)
 1317:         #print_(group.wos, self.logfile)
 1318:         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":1318
 *         #print_("Processor %i: Current group has %i wos and invariant value is %i" % (rank, len(group.get_wos()), group.value), self.logfile)
 *         #print_(group.wos, self.logfile)
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < M:
 *             wo = wos[i]
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_bond_variables = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
 1319:         for i from 0 <= i < M:
  /* "water_algorithm_cython.pyx":1319
 *         #print_(group.wos, self.logfile)
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         for i from 0 <= i < M:             # <<<<<<<<<<<<<<
 *             wo = wos[i]
 *             if not self.is_symmetric_with_another_result(group,  wo, molecule_no, False, symmetry_operations, result_group_level, self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, bond_variables):
 */
  __pyx_t_6 = __pyx_v_M;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_6; __pyx_v_i++) {
 1320:             wo = wos[i]
    /* "water_algorithm_cython.pyx":1320
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         for i from 0 <= i < M:
 *             wo = wos[i]             # <<<<<<<<<<<<<<
 *             if not self.is_symmetric_with_another_result(group,  wo, molecule_no, False, symmetry_operations, result_group_level, self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, bond_variables):
 *                 new_water_orientations[count[0]] = wo
 */
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_wos), __pyx_v_i, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
    if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_XDEC_MEMVIEW(&__pyx_v_wo, 1);
    __pyx_v_wo = __pyx_t_7;
    __pyx_t_7.memview = NULL;
    __pyx_t_7.data = NULL;
 1321:             if not self.is_symmetric_with_another_result(group,  wo, molecule_no, False, symmetry_operations, result_group_level, self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, bond_variables):
    /* "water_algorithm_cython.pyx":1321
 *         for i from 0 <= i < M:
 *             wo = wos[i]
 *             if not self.is_symmetric_with_another_result(group,  wo, molecule_no, False, symmetry_operations, result_group_level, self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, bond_variables):             # <<<<<<<<<<<<<<
 *                 new_water_orientations[count[0]] = wo
 *                 count[0] += 1
 */
    __pyx_t_2 = (!((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->is_symmetric_with_another_result(__pyx_v_self, __pyx_v_group, __pyx_v_wo, __pyx_v_molecule_no, 0, __pyx_v_symmetry_operations, __pyx_v_result_group_level, __pyx_v_self_symmetry_groups, __pyx_v_save_self_symmetry_groups, __pyx_v_pending_self_symmetry_operations, __pyx_v_parent_self_symmetry_group, __pyx_v_bond_variables));
    if (__pyx_t_2) {
 1322:                 new_water_orientations[count[0]] = wo
      /* "water_algorithm_cython.pyx":1322
 *             wo = wos[i]
 *             if not self.is_symmetric_with_another_result(group,  wo, molecule_no, False, symmetry_operations, result_group_level, self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, bond_variables):
 *                 new_water_orientations[count[0]] = wo             # <<<<<<<<<<<<<<
 *                 count[0] += 1
 *         #print_("Processor %i finished  group, resulted %i symmetry distinct results, loaded symmetries for %i wos" % (rank, count[0], self.symmetries_loaded), self.logfile)
 */
      __pyx_t_9 = -1;
      __pyx_t_8.data = __pyx_v_new_water_orientations.data;
      __pyx_t_8.memview = __pyx_v_new_water_orientations.memview;
      __PYX_INC_MEMVIEW(&__pyx_t_8, 0);
      {
    Py_ssize_t __pyx_tmp_idx = (__pyx_v_count[0]);
    Py_ssize_t __pyx_tmp_shape = __pyx_v_new_water_orientations.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_new_water_orientations.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_8.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_8.shape[0] = __pyx_v_new_water_orientations.shape[1];
__pyx_t_8.strides[0] = __pyx_v_new_water_orientations.strides[1];
    __pyx_t_8.suboffsets[0] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_v_wo, __pyx_t_8, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
 1323:                 count[0] += 1
      /* "water_algorithm_cython.pyx":1323
 *             if not self.is_symmetric_with_another_result(group,  wo, molecule_no, False, symmetry_operations, result_group_level, self_symmetry_groups, save_self_symmetry_groups, pending_self_symmetry_operations, parent_self_symmetry_group, bond_variables):
 *                 new_water_orientations[count[0]] = wo
 *                 count[0] += 1             # <<<<<<<<<<<<<<
 *         #print_("Processor %i finished  group, resulted %i symmetry distinct results, loaded symmetries for %i wos" % (rank, count[0], self.symmetries_loaded), self.logfile)
 *         return new_water_orientations
 */
      __pyx_t_10 = 0;
      (__pyx_v_count[__pyx_t_10]) = ((__pyx_v_count[__pyx_t_10]) + 1);
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
 1324:         #print_("Processor %i finished  group, resulted %i symmetry distinct results, loaded symmetries for %i wos" % (rank, count[0], self.symmetries_loaded), self.logfile)
 1325:         return new_water_orientations
  /* "water_algorithm_cython.pyx":1325
 *                 count[0] += 1
 *         #print_("Processor %i finished  group, resulted %i symmetry distinct results, loaded symmetries for %i wos" % (rank, count[0], self.symmetries_loaded), self.logfile)
 *         return new_water_orientations             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] remove_symmetries_no_invariants(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations,  np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos, unsigned char molecule_no, list symmetry_operations, list self_symmetry_groups, bool save_self_symmetry_groups):
 */
  __PYX_INC_MEMVIEW(&__pyx_v_new_water_orientations, 0);
  __pyx_r = __pyx_v_new_water_orientations;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wos.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.remove_symmetries_for_single_group", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_r;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wos.rcbuffer->pybuffer);
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError,"Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_wo, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_wos);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1326: 
 1327:     cdef np.ndarray[DTYPE2_t, ndim=2] remove_symmetries_no_invariants(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations,  np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos, unsigned char molecule_no, list symmetry_operations, list self_symmetry_groups, bool save_self_symmetry_groups):
/* "water_algorithm_cython.pyx":1327
 *         return new_water_orientations
 * 
 *     cdef np.ndarray[DTYPE2_t, ndim=2] remove_symmetries_no_invariants(self, np.ndarray[DTYPE2_t, ndim=2] water_orientations,  np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos, unsigned char molecule_no, list symmetry_operations, list self_symmetry_groups, bool save_self_symmetry_groups):             # <<<<<<<<<<<<<<
 *         """
 *             Removes symmetries wihout using invariants
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_remove_symmetries_no_invariants(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyArrayObject *__pyx_v_water_orientations, CYTHON_UNUSED PyArrayObject *__pyx_v_nearest_neighbors_nos, CYTHON_UNUSED unsigned char __pyx_v_molecule_no, PyObject *__pyx_v_symmetry_operations, PyObject *__pyx_v_self_symmetry_groups, PyBoolObject *__pyx_v_save_self_symmetry_groups) {
  int __pyx_v_length_before;
  PyArrayObject *__pyx_v_results = 0;
  PyArrayObject *__pyx_v_symmetry = 0;
  PyArrayObject *__pyx_v_wo = 0;
  PyArrayObject *__pyx_v_wo_2 = 0;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  int __pyx_v_l;
  int __pyx_v_m;
  int __pyx_v_N;
  int __pyx_v_M;
  int __pyx_v_L;
  int __pyx_v_J;
  int __pyx_v_I;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_symmetry_found;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_self_symmetry_found;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_copy_found;
  struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *__pyx_v_symmetry_operation = 0;
  PyObject *__pyx_v_self_symmetry_operations = 0;
  struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_self_symmetry_group = 0;
  PyObject *__pyx_v_new_self_symmetry_groups = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nearest_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_nearest_neighbors_nos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_results;
  __Pyx_Buffer __pyx_pybuffer_results;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_symmetry;
  __Pyx_Buffer __pyx_pybuffer_symmetry;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wo;
  __Pyx_Buffer __pyx_pybuffer_wo;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wo_2;
  __Pyx_Buffer __pyx_pybuffer_wo_2;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_symmetries_no_invariants", 0);
  __pyx_pybuffer_results.pybuffer.buf = NULL;
  __pyx_pybuffer_results.refcount = 0;
  __pyx_pybuffernd_results.data = NULL;
  __pyx_pybuffernd_results.rcbuffer = &__pyx_pybuffer_results;
  __pyx_pybuffer_symmetry.pybuffer.buf = NULL;
  __pyx_pybuffer_symmetry.refcount = 0;
  __pyx_pybuffernd_symmetry.data = NULL;
  __pyx_pybuffernd_symmetry.rcbuffer = &__pyx_pybuffer_symmetry;
  __pyx_pybuffer_wo.pybuffer.buf = NULL;
  __pyx_pybuffer_wo.refcount = 0;
  __pyx_pybuffernd_wo.data = NULL;
  __pyx_pybuffernd_wo.rcbuffer = &__pyx_pybuffer_wo;
  __pyx_pybuffer_wo_2.pybuffer.buf = NULL;
  __pyx_pybuffer_wo_2.refcount = 0;
  __pyx_pybuffernd_wo_2.data = NULL;
  __pyx_pybuffernd_wo_2.rcbuffer = &__pyx_pybuffer_wo_2;
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
  __pyx_pybuffer_nearest_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_nearest_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_nearest_neighbors_nos.data = NULL;
  __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer = &__pyx_pybuffer_nearest_neighbors_nos;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_water_orientations.diminfo[1].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_water_orientations.diminfo[1].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_v_nearest_neighbors_nos, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[2];
 1328:         """
 1329:             Removes symmetries wihout using invariants
 1330:             NOTE: Very slow and should only be used for debugging purposes
 1331:         """
 1332:         cdef int length_before
 1333:         length_before = len(water_orientations)
  /* "water_algorithm_cython.pyx":1333
 *         """
 *         cdef int length_before
 *         length_before = len(water_orientations)             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[DTYPE2_t, ndim=2] results = np.zeros((0, water_orientations.shape[1]), dtype=DTYPE2)
 */
  __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_water_orientations)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_length_before = __pyx_t_1;
 1334: 
 1335:         cdef np.ndarray[DTYPE2_t, ndim=2] results = np.zeros((0, water_orientations.shape[1]), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":1335
 *         length_before = len(water_orientations)
 * 
 *         cdef np.ndarray[DTYPE2_t, ndim=2] results = np.zeros((0, water_orientations.shape[1]), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         #cdef np.ndarray[DTYPE2_t, ndim=2] symmetries
 *         cdef np.ndarray[DTYPE2_t, ndim=1] symmetry, wo, wo_2
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_water_orientations->dimensions[1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_results = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_results.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_results.diminfo[1].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_results.diminfo[1].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_results = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
 1336:         #cdef np.ndarray[DTYPE2_t, ndim=2] symmetries
 1337:         cdef np.ndarray[DTYPE2_t, ndim=1] symmetry, wo, wo_2
 1338:         cdef int i, j, k, l, m, N = water_orientations.shape[0], M, L = len(symmetry_operations), J, I
  /* "water_algorithm_cython.pyx":1338
 *         #cdef np.ndarray[DTYPE2_t, ndim=2] symmetries
 *         cdef np.ndarray[DTYPE2_t, ndim=1] symmetry, wo, wo_2
 *         cdef int i, j, k, l, m, N = water_orientations.shape[0], M, L = len(symmetry_operations), J, I             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t symmetry_found, self_symmetry_found, copy_found
 *         cdef SymmetryOperation symmetry_operation
 */
  __pyx_v_N = (__pyx_v_water_orientations->dimensions[0]);
  if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_L = __pyx_t_1;
 1339:         cdef DTYPE2_t symmetry_found, self_symmetry_found, copy_found
 1340:         cdef SymmetryOperation symmetry_operation
 1341:         cdef list self_symmetry_operations
 1342:         cdef SelfSymmetryGroup self_symmetry_group
 1343:         cdef list new_self_symmetry_groups = []
  /* "water_algorithm_cython.pyx":1343
 *         cdef list self_symmetry_operations
 *         cdef SelfSymmetryGroup self_symmetry_group
 *         cdef list new_self_symmetry_groups = []             # <<<<<<<<<<<<<<
 * 
 *         print_parallel("Performing symmetry check for %i geometries and %i symmetry operations" % (length_before, L), self.logfile)
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_new_self_symmetry_groups = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
 1344: 
 1345:         print_parallel("Performing symmetry check for %i geometries and %i symmetry operations" % (length_before, L), self.logfile)
  /* "water_algorithm_cython.pyx":1345
 *         cdef list new_self_symmetry_groups = []
 * 
 *         print_parallel("Performing symmetry check for %i geometries and %i symmetry operations" % (length_before, L), self.logfile)             # <<<<<<<<<<<<<<
 * 
 *         for i from 0 <= i < N:
 */
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyInt_FromLong(__pyx_v_length_before); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_L); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_91), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self->logfile);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
  __Pyx_GIVEREF(__pyx_v_self->logfile);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1346: 
 1347:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":1347
 *         print_parallel("Performing symmetry check for %i geometries and %i symmetry operations" % (length_before, L), self.logfile)
 * 
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             if i % 50 == 0:
 *                 print i
 */
  __pyx_t_7 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 1348:             if i % 50 == 0:
    /* "water_algorithm_cython.pyx":1348
 * 
 *         for i from 0 <= i < N:
 *             if i % 50 == 0:             # <<<<<<<<<<<<<<
 *                 print i
 *             self_symmetry_operations = []
 */
    __pyx_t_8 = (__Pyx_mod_long(__pyx_v_i, 50) == 0);
    if (__pyx_t_8) {
 1349:                 print i
      /* "water_algorithm_cython.pyx":1349
 *         for i from 0 <= i < N:
 *             if i % 50 == 0:
 *                 print i             # <<<<<<<<<<<<<<
 *             self_symmetry_operations = []
 *             wo = water_orientations[i]
 */
      __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_PrintOne(0, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1349; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
 1350:             self_symmetry_operations = []
    /* "water_algorithm_cython.pyx":1350
 *             if i % 50 == 0:
 *                 print i
 *             self_symmetry_operations = []             # <<<<<<<<<<<<<<
 *             wo = water_orientations[i]
 * 
 */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF(((PyObject *)__pyx_v_self_symmetry_operations));
    __pyx_v_self_symmetry_operations = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
 1351:             wo = water_orientations[i]
    /* "water_algorithm_cython.pyx":1351
 *                 print i
 *             self_symmetry_operations = []
 *             wo = water_orientations[i]             # <<<<<<<<<<<<<<
 * 
 *             #symmetries = self.get_symmetries(wo, nearest_neighbors_nos, symmetry_operations)
 */
    __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_water_orientations), __pyx_v_i, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo.rcbuffer->pybuffer);
      __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_10 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo.rcbuffer->pybuffer, (PyObject*)__pyx_v_wo, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        }
      }
      __pyx_pybuffernd_wo.diminfo[0].strides = __pyx_pybuffernd_wo.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wo.diminfo[0].shape = __pyx_pybuffernd_wo.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_9 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_wo));
    __pyx_v_wo = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;
 1352: 
 1353:             #symmetries = self.get_symmetries(wo, nearest_neighbors_nos, symmetry_operations)
 1354:             symmetry_found = 0
    /* "water_algorithm_cython.pyx":1354
 * 
 *             #symmetries = self.get_symmetries(wo, nearest_neighbors_nos, symmetry_operations)
 *             symmetry_found = 0             # <<<<<<<<<<<<<<
 *             copy_found = 0
 *             M = results.shape[0]
 */
    __pyx_v_symmetry_found = 0;
 1355:             copy_found = 0
    /* "water_algorithm_cython.pyx":1355
 *             #symmetries = self.get_symmetries(wo, nearest_neighbors_nos, symmetry_operations)
 *             symmetry_found = 0
 *             copy_found = 0             # <<<<<<<<<<<<<<
 *             M = results.shape[0]
 *             for k from 0 <= k < L:
 */
    __pyx_v_copy_found = 0;
 1356:             M = results.shape[0]
    /* "water_algorithm_cython.pyx":1356
 *             symmetry_found = 0
 *             copy_found = 0
 *             M = results.shape[0]             # <<<<<<<<<<<<<<
 *             for k from 0 <= k < L:
 *                 symmetry_operation = symmetry_operations[k]
 */
    __pyx_v_M = (__pyx_v_results->dimensions[0]);
 1357:             for k from 0 <= k < L:
    /* "water_algorithm_cython.pyx":1357
 *             copy_found = 0
 *             M = results.shape[0]
 *             for k from 0 <= k < L:             # <<<<<<<<<<<<<<
 *                 symmetry_operation = symmetry_operations[k]
 *                 symmetry = symmetry_operation.apply(wo,  self, self.nearest_neighbors_nos, False)
 */
    __pyx_t_10 = __pyx_v_L;
    for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_10; __pyx_v_k++) {
 1358:                 symmetry_operation = symmetry_operations[k]
      /* "water_algorithm_cython.pyx":1358
 *             M = results.shape[0]
 *             for k from 0 <= k < L:
 *                 symmetry_operation = symmetry_operations[k]             # <<<<<<<<<<<<<<
 *                 symmetry = symmetry_operation.apply(wo,  self, self.nearest_neighbors_nos, False)
 *                 for j from 0 <= j < M:
 */
      if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      if (!(likely(((PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_k)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_k), __pyx_ptype_10symmetries_25symmetry_operation_cython_SymmetryOperation))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_k);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry_operation));
      __pyx_v_symmetry_operation = ((struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_t_2);
      __pyx_t_2 = 0;
 1359:                 symmetry = symmetry_operation.apply(wo,  self, self.nearest_neighbors_nos, False)
      /* "water_algorithm_cython.pyx":1359
 *             for k from 0 <= k < L:
 *                 symmetry_operation = symmetry_operations[k]
 *                 symmetry = symmetry_operation.apply(wo,  self, self.nearest_neighbors_nos, False)             # <<<<<<<<<<<<<<
 *                 for j from 0 <= j < M:
 *                     wo_2 = results[j]
 */
      __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE2_t(((PyObject *)__pyx_v_wo));
      if (unlikely(!__pyx_t_14.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE_t(__pyx_t_2);
      if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_v_symmetry_operation->__pyx_vtab)->apply(__pyx_v_symmetry_operation, __pyx_t_14, __pyx_v_self, __pyx_t_15, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer);
        __pyx_t_16 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_2), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_16 < 0)) {
          PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer, (PyObject*)__pyx_v_symmetry, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
          }
        }
        __pyx_pybuffernd_symmetry.diminfo[0].strides = __pyx_pybuffernd_symmetry.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_symmetry.diminfo[0].shape = __pyx_pybuffernd_symmetry.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry));
      __pyx_v_symmetry = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
 1360:                 for j from 0 <= j < M:
      /* "water_algorithm_cython.pyx":1360
 *                 symmetry_operation = symmetry_operations[k]
 *                 symmetry = symmetry_operation.apply(wo,  self, self.nearest_neighbors_nos, False)
 *                 for j from 0 <= j < M:             # <<<<<<<<<<<<<<
 *                     wo_2 = results[j]
 *                     copy_found = np.all(np.equal(wo_2, wo))
 */
      __pyx_t_16 = __pyx_v_M;
      for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_16; __pyx_v_j++) {
 1361:                     wo_2 = results[j]
        /* "water_algorithm_cython.pyx":1361
 *                 symmetry = symmetry_operation.apply(wo,  self, self.nearest_neighbors_nos, False)
 *                 for j from 0 <= j < M:
 *                     wo_2 = results[j]             # <<<<<<<<<<<<<<
 *                     copy_found = np.all(np.equal(wo_2, wo))
 *                     symmetry_found = np.all(np.equal(wo_2, symmetry))
 */
        __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_results), __pyx_v_j, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_9 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer);
          __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_17 < 0)) {
            PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer, (PyObject*)__pyx_v_wo_2, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            }
          }
          __pyx_pybuffernd_wo_2.diminfo[0].strides = __pyx_pybuffernd_wo_2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wo_2.diminfo[0].shape = __pyx_pybuffernd_wo_2.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_9 = 0;
        __Pyx_XDECREF(((PyObject *)__pyx_v_wo_2));
        __pyx_v_wo_2 = ((PyArrayObject *)__pyx_t_2);
        __pyx_t_2 = 0;
 1362:                     copy_found = np.all(np.equal(wo_2, wo))
        /* "water_algorithm_cython.pyx":1362
 *                 for j from 0 <= j < M:
 *                     wo_2 = results[j]
 *                     copy_found = np.all(np.equal(wo_2, wo))             # <<<<<<<<<<<<<<
 *                     symmetry_found = np.all(np.equal(wo_2, symmetry))
 *                     if symmetry_found:
 */
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__all); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__equal); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_wo_2));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_wo_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_wo_2));
        __Pyx_INCREF(((PyObject *)__pyx_v_wo));
        PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_wo));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __pyx_t_18 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_4); if (unlikely((__pyx_t_18 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_v_copy_found = __pyx_t_18;
 1363:                     symmetry_found = np.all(np.equal(wo_2, symmetry))
        /* "water_algorithm_cython.pyx":1363
 *                     wo_2 = results[j]
 *                     copy_found = np.all(np.equal(wo_2, wo))
 *                     symmetry_found = np.all(np.equal(wo_2, symmetry))             # <<<<<<<<<<<<<<
 *                     if symmetry_found:
 *                         print_("SYMMETRY FOUND ", self.logfile)
 */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__all); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__equal); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_INCREF(((PyObject *)__pyx_v_wo_2));
        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_wo_2));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_wo_2));
        __Pyx_INCREF(((PyObject *)__pyx_v_symmetry));
        PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_symmetry));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry));
        __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        __pyx_t_18 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_5); if (unlikely((__pyx_t_18 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_v_symmetry_found = __pyx_t_18;
 1364:                     if symmetry_found:
        /* "water_algorithm_cython.pyx":1364
 *                     copy_found = np.all(np.equal(wo_2, wo))
 *                     symmetry_found = np.all(np.equal(wo_2, symmetry))
 *                     if symmetry_found:             # <<<<<<<<<<<<<<
 *                         print_("SYMMETRY FOUND ", self.logfile)
 *                         print_(symmetry_operation, self.logfile)
 */
        if (__pyx_v_symmetry_found) {
 1365:                         print_("SYMMETRY FOUND ", self.logfile)
          /* "water_algorithm_cython.pyx":1365
 *                     symmetry_found = np.all(np.equal(wo_2, symmetry))
 *                     if symmetry_found:
 *                         print_("SYMMETRY FOUND ", self.logfile)             # <<<<<<<<<<<<<<
 *                         print_(symmetry_operation, self.logfile)
 *                         print_(symmetry_operation.nn_change_matrix, self.logfile)
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_92));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_92));
          __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_92));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1366:                         print_(symmetry_operation, self.logfile)
          /* "water_algorithm_cython.pyx":1366
 *                     if symmetry_found:
 *                         print_("SYMMETRY FOUND ", self.logfile)
 *                         print_(symmetry_operation, self.logfile)             # <<<<<<<<<<<<<<
 *                         print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                         print_(symmetry_operation, self.logfile)
 */
          __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_symmetry_operation));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1367:                         print_(symmetry_operation.nn_change_matrix, self.logfile)
          /* "water_algorithm_cython.pyx":1367
 *                         print_("SYMMETRY FOUND ", self.logfile)
 *                         print_(symmetry_operation, self.logfile)
 *                         print_(symmetry_operation.nn_change_matrix, self.logfile)             # <<<<<<<<<<<<<<
 *                         print_(symmetry_operation, self.logfile)
 * 
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1368:                         print_(symmetry_operation, self.logfile)
          /* "water_algorithm_cython.pyx":1368
 *                         print_(symmetry_operation, self.logfile)
 *                         print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                         print_(symmetry_operation, self.logfile)             # <<<<<<<<<<<<<<
 * 
 *                         print_(wo, self.logfile)
 */
          __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_symmetry_operation));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1369: 
 1370:                         print_(wo, self.logfile)
          /* "water_algorithm_cython.pyx":1370
 *                         print_(symmetry_operation, self.logfile)
 * 
 *                         print_(wo, self.logfile)             # <<<<<<<<<<<<<<
 *                         print_(wo_2, self.logfile)
 *                         print_("---", self.logfile)
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_v_wo));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_wo));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1371:                         print_(wo_2, self.logfile)
          /* "water_algorithm_cython.pyx":1371
 * 
 *                         print_(wo, self.logfile)
 *                         print_(wo_2, self.logfile)             # <<<<<<<<<<<<<<
 *                         print_("---", self.logfile)
 *                         if symmetry_operation.additional_requirements is not None:
 */
          __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_v_wo_2));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_wo_2));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_wo_2));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1372:                         print_("---", self.logfile)
          /* "water_algorithm_cython.pyx":1372
 *                         print_(wo, self.logfile)
 *                         print_(wo_2, self.logfile)
 *                         print_("---", self.logfile)             # <<<<<<<<<<<<<<
 *                         if symmetry_operation.additional_requirements is not None:
 *                             print wo
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_93));
          __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1373:                         if symmetry_operation.additional_requirements is not None:
          /* "water_algorithm_cython.pyx":1373
 *                         print_(wo_2, self.logfile)
 *                         print_("---", self.logfile)
 *                         if symmetry_operation.additional_requirements is not None:             # <<<<<<<<<<<<<<
 *                             print wo
 *                             print wo_2
 */
          __pyx_t_8 = (((PyObject *)__pyx_v_symmetry_operation->additional_requirements) != Py_None);
          if (__pyx_t_8) {
 1374:                             print wo
            /* "water_algorithm_cython.pyx":1374
 *                         print_("---", self.logfile)
 *                         if symmetry_operation.additional_requirements is not None:
 *                             print wo             # <<<<<<<<<<<<<<
 *                             print wo_2
 *                             print symmetry_operation.molecule_change_matrix
 */
            if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_wo)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1375:                             print wo_2
            /* "water_algorithm_cython.pyx":1375
 *                         if symmetry_operation.additional_requirements is not None:
 *                             print wo
 *                             print wo_2             # <<<<<<<<<<<<<<
 *                             print symmetry_operation.molecule_change_matrix
 *                             print np.dot(symmetry_operation.translation_vector, self.atoms.get_cell())
 */
            if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_wo_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1376:                             print symmetry_operation.molecule_change_matrix
            /* "water_algorithm_cython.pyx":1376
 *                             print wo
 *                             print wo_2
 *                             print symmetry_operation.molecule_change_matrix             # <<<<<<<<<<<<<<
 *                             print np.dot(symmetry_operation.translation_vector, self.atoms.get_cell())
 *                             print symmetry_operation
 */
            if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1377:                             print np.dot(symmetry_operation.translation_vector, self.atoms.get_cell())
            /* "water_algorithm_cython.pyx":1377
 *                             print wo_2
 *                             print symmetry_operation.molecule_change_matrix
 *                             print np.dot(symmetry_operation.translation_vector, self.atoms.get_cell())             # <<<<<<<<<<<<<<
 *                             print symmetry_operation
 *                             print symmetry_operation.additional_requirements
 */
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__dot); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__get_cell); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation->translation_vector));
            PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_symmetry_operation->translation_vector));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation->translation_vector));
            PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_t_5 = 0;
            __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
            if (__Pyx_PrintOne(0, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1378:                             print symmetry_operation
            /* "water_algorithm_cython.pyx":1378
 *                             print symmetry_operation.molecule_change_matrix
 *                             print np.dot(symmetry_operation.translation_vector, self.atoms.get_cell())
 *                             print symmetry_operation             # <<<<<<<<<<<<<<
 *                             print symmetry_operation.additional_requirements
 *                             raw_input()
 */
            if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_symmetry_operation)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1379:                             print symmetry_operation.additional_requirements
            /* "water_algorithm_cython.pyx":1379
 *                             print np.dot(symmetry_operation.translation_vector, self.atoms.get_cell())
 *                             print symmetry_operation
 *                             print symmetry_operation.additional_requirements             # <<<<<<<<<<<<<<
 *                             raw_input()
 *                         #self.check_symmetricity(wo, wo_2, symmetry_operation)
 */
            if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_symmetry_operation->additional_requirements)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1380:                             raw_input()
            /* "water_algorithm_cython.pyx":1380
 *                             print symmetry_operation
 *                             print symmetry_operation.additional_requirements
 *                             raw_input()             # <<<<<<<<<<<<<<
 *                         #self.check_symmetricity(wo, wo_2, symmetry_operation)
 *                         break
 */
            __pyx_t_5 = PyObject_Call(__pyx_builtin_raw_input, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            goto __pyx_L11;
          }
          __pyx_L11:;
 1381:                         #self.check_symmetricity(wo, wo_2, symmetry_operation)
 1382:                         break
          /* "water_algorithm_cython.pyx":1382
 *                             raw_input()
 *                         #self.check_symmetricity(wo, wo_2, symmetry_operation)
 *                         break             # <<<<<<<<<<<<<<
 *                     if  copy_found:
 *                         print_("Copy found", self.logfile)
 */
          goto __pyx_L9_break;
          goto __pyx_L10;
        }
        __pyx_L10:;
 1383:                     if  copy_found:
        /* "water_algorithm_cython.pyx":1383
 *                         #self.check_symmetricity(wo, wo_2, symmetry_operation)
 *                         break
 *                     if  copy_found:             # <<<<<<<<<<<<<<
 *                         print_("Copy found", self.logfile)
 *                         print_(wo, self.logfile)
 */
        if (__pyx_v_copy_found) {
 1384:                         print_("Copy found", self.logfile)
          /* "water_algorithm_cython.pyx":1384
 *                         break
 *                     if  copy_found:
 *                         print_("Copy found", self.logfile)             # <<<<<<<<<<<<<<
 *                         print_(wo, self.logfile)
 *                         print_("---", self.logfile)
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_94));
          PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_94));
          __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_94));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1385:                         print_(wo, self.logfile)
          /* "water_algorithm_cython.pyx":1385
 *                     if  copy_found:
 *                         print_("Copy found", self.logfile)
 *                         print_(wo, self.logfile)             # <<<<<<<<<<<<<<
 *                         print_("---", self.logfile)
 *                         break
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(((PyObject *)__pyx_v_wo));
          PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_wo));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1386:                         print_("---", self.logfile)
          /* "water_algorithm_cython.pyx":1386
 *                         print_("Copy found", self.logfile)
 *                         print_(wo, self.logfile)
 *                         print_("---", self.logfile)             # <<<<<<<<<<<<<<
 *                         break
 *                 if symmetry_found or copy_found:
 */
          __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
          PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_93));
          __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
          __Pyx_INCREF(__pyx_v_self->logfile);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
          __Pyx_GIVEREF(__pyx_v_self->logfile);
          __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1387:                         break
          /* "water_algorithm_cython.pyx":1387
 *                         print_(wo, self.logfile)
 *                         print_("---", self.logfile)
 *                         break             # <<<<<<<<<<<<<<
 *                 if symmetry_found or copy_found:
 *                     break
 */
          goto __pyx_L9_break;
          goto __pyx_L12;
        }
        __pyx_L12:;
      }
      __pyx_L9_break:;
 1388:                 if symmetry_found or copy_found:
      /* "water_algorithm_cython.pyx":1388
 *                         print_("---", self.logfile)
 *                         break
 *                 if symmetry_found or copy_found:             # <<<<<<<<<<<<<<
 *                     break
 *                 J = len(new_self_symmetry_groups)
 */
      if (!__pyx_v_symmetry_found) {
        __pyx_t_8 = __pyx_v_copy_found;
      } else {
        __pyx_t_8 = __pyx_v_symmetry_found;
      }
      if (__pyx_t_8) {
 1389:                     break
        /* "water_algorithm_cython.pyx":1389
 *                         break
 *                 if symmetry_found or copy_found:
 *                     break             # <<<<<<<<<<<<<<
 *                 J = len(new_self_symmetry_groups)
 *                 for l from 0 <= l < J:
 */
        goto __pyx_L7_break;
        goto __pyx_L13;
      }
      __pyx_L13:;
 1390:                 J = len(new_self_symmetry_groups)
      /* "water_algorithm_cython.pyx":1390
 *                 if symmetry_found or copy_found:
 *                     break
 *                 J = len(new_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *                 for l from 0 <= l < J:
 *                     self_symmetry_group = new_self_symmetry_groups[l]
 */
      __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_new_self_symmetry_groups)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_J = __pyx_t_1;
 1391:                 for l from 0 <= l < J:
      /* "water_algorithm_cython.pyx":1391
 *                     break
 *                 J = len(new_self_symmetry_groups)
 *                 for l from 0 <= l < J:             # <<<<<<<<<<<<<<
 *                     self_symmetry_group = new_self_symmetry_groups[l]
 *                     I = self_symmetry_group.water_orientations.shape[0]
 */
      __pyx_t_16 = __pyx_v_J;
      for (__pyx_v_l = 0; __pyx_v_l < __pyx_t_16; __pyx_v_l++) {
 1392:                     self_symmetry_group = new_self_symmetry_groups[l]
        /* "water_algorithm_cython.pyx":1392
 *                 J = len(new_self_symmetry_groups)
 *                 for l from 0 <= l < J:
 *                     self_symmetry_group = new_self_symmetry_groups[l]             # <<<<<<<<<<<<<<
 *                     I = self_symmetry_group.water_orientations.shape[0]
 *                     for m from 0 <= m < I:
 */
        if (!(likely(((PyList_GET_ITEM(__pyx_v_new_self_symmetry_groups, __pyx_v_l)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_new_self_symmetry_groups, __pyx_v_l), __pyx_ptype_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_4 = PyList_GET_ITEM(__pyx_v_new_self_symmetry_groups, __pyx_v_l);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_XDECREF(((PyObject *)__pyx_v_self_symmetry_group));
        __pyx_v_self_symmetry_group = ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)__pyx_t_4);
        __pyx_t_4 = 0;
 1393:                     I = self_symmetry_group.water_orientations.shape[0]
        /* "water_algorithm_cython.pyx":1393
 *                 for l from 0 <= l < J:
 *                     self_symmetry_group = new_self_symmetry_groups[l]
 *                     I = self_symmetry_group.water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *                     for m from 0 <= m < I:
 *                         wo_2 = self_symmetry_group.water_orientations[m]
 */
        __pyx_v_I = (__pyx_v_self_symmetry_group->water_orientations->dimensions[0]);
 1394:                     for m from 0 <= m < I:
        /* "water_algorithm_cython.pyx":1394
 *                     self_symmetry_group = new_self_symmetry_groups[l]
 *                     I = self_symmetry_group.water_orientations.shape[0]
 *                     for m from 0 <= m < I:             # <<<<<<<<<<<<<<
 *                         wo_2 = self_symmetry_group.water_orientations[m]
 * 
 */
        __pyx_t_17 = __pyx_v_I;
        for (__pyx_v_m = 0; __pyx_v_m < __pyx_t_17; __pyx_v_m++) {
 1395:                         wo_2 = self_symmetry_group.water_orientations[m]
          /* "water_algorithm_cython.pyx":1395
 *                     I = self_symmetry_group.water_orientations.shape[0]
 *                     for m from 0 <= m < I:
 *                         wo_2 = self_symmetry_group.water_orientations[m]             # <<<<<<<<<<<<<<
 * 
 *                         symmetry_found = np.all(np.equal(wo_2, symmetry))
 */
          __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self_symmetry_group->water_orientations), __pyx_v_m, sizeof(int), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_9 = ((PyArrayObject *)__pyx_t_4);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer);
            __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
            if (unlikely(__pyx_t_19 < 0)) {
              PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer, (PyObject*)__pyx_v_wo_2, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
              }
            }
            __pyx_pybuffernd_wo_2.diminfo[0].strides = __pyx_pybuffernd_wo_2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wo_2.diminfo[0].shape = __pyx_pybuffernd_wo_2.rcbuffer->pybuffer.shape[0];
            if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_9 = 0;
          __Pyx_XDECREF(((PyObject *)__pyx_v_wo_2));
          __pyx_v_wo_2 = ((PyArrayObject *)__pyx_t_4);
          __pyx_t_4 = 0;
 1396: 
 1397:                         symmetry_found = np.all(np.equal(wo_2, symmetry))
          /* "water_algorithm_cython.pyx":1397
 *                         wo_2 = self_symmetry_group.water_orientations[m]
 * 
 *                         symmetry_found = np.all(np.equal(wo_2, symmetry))             # <<<<<<<<<<<<<<
 *                         if symmetry_found:
 *                             print_("SYMMETRY FOUND ", self.logfile)
 */
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__all); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__equal); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_INCREF(((PyObject *)__pyx_v_wo_2));
          PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_wo_2));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_wo_2));
          __Pyx_INCREF(((PyObject *)__pyx_v_symmetry));
          PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_symmetry));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry));
          __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
          __pyx_t_18 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_3); if (unlikely((__pyx_t_18 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_v_symmetry_found = __pyx_t_18;
 1398:                         if symmetry_found:
          /* "water_algorithm_cython.pyx":1398
 * 
 *                         symmetry_found = np.all(np.equal(wo_2, symmetry))
 *                         if symmetry_found:             # <<<<<<<<<<<<<<
 *                             print_("SYMMETRY FOUND ", self.logfile)
 *                             print_(symmetry_operation, self.logfile)
 */
          if (__pyx_v_symmetry_found) {
 1399:                             print_("SYMMETRY FOUND ", self.logfile)
            /* "water_algorithm_cython.pyx":1399
 *                         symmetry_found = np.all(np.equal(wo_2, symmetry))
 *                         if symmetry_found:
 *                             print_("SYMMETRY FOUND ", self.logfile)             # <<<<<<<<<<<<<<
 *                             print_(symmetry_operation, self.logfile)
 *                             print_(symmetry_operation.nn_change_matrix, self.logfile)
 */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_kp_s_92));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_92));
            __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_92));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1400:                             print_(symmetry_operation, self.logfile)
            /* "water_algorithm_cython.pyx":1400
 *                         if symmetry_found:
 *                             print_("SYMMETRY FOUND ", self.logfile)
 *                             print_(symmetry_operation, self.logfile)             # <<<<<<<<<<<<<<
 *                             print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                             print_(symmetry_operation, self.logfile)
 */
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_symmetry_operation));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1401:                             print_(symmetry_operation.nn_change_matrix, self.logfile)
            /* "water_algorithm_cython.pyx":1401
 *                             print_("SYMMETRY FOUND ", self.logfile)
 *                             print_(symmetry_operation, self.logfile)
 *                             print_(symmetry_operation.nn_change_matrix, self.logfile)             # <<<<<<<<<<<<<<
 *                             print_(symmetry_operation, self.logfile)
 *                             print_(wo, self.logfile)
 */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1402:                             print_(symmetry_operation, self.logfile)
            /* "water_algorithm_cython.pyx":1402
 *                             print_(symmetry_operation, self.logfile)
 *                             print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                             print_(symmetry_operation, self.logfile)             # <<<<<<<<<<<<<<
 *                             print_(wo, self.logfile)
 *                             print_(wo_2, self.logfile)
 */
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_symmetry_operation));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1403:                             print_(wo, self.logfile)
            /* "water_algorithm_cython.pyx":1403
 *                             print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                             print_(symmetry_operation, self.logfile)
 *                             print_(wo, self.logfile)             # <<<<<<<<<<<<<<
 *                             print_(wo_2, self.logfile)
 *                             print_("---", self.logfile)
 */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_v_wo));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_wo));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1404:                             print_(wo_2, self.logfile)
            /* "water_algorithm_cython.pyx":1404
 *                             print_(symmetry_operation, self.logfile)
 *                             print_(wo, self.logfile)
 *                             print_(wo_2, self.logfile)             # <<<<<<<<<<<<<<
 *                             print_("---", self.logfile)
 *                             break
 */
            __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_v_wo_2));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_wo_2));
            __Pyx_GIVEREF(((PyObject *)__pyx_v_wo_2));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1405:                             print_("---", self.logfile)
            /* "water_algorithm_cython.pyx":1405
 *                             print_(wo, self.logfile)
 *                             print_(wo_2, self.logfile)
 *                             print_("---", self.logfile)             # <<<<<<<<<<<<<<
 *                             break
 *                     if symmetry_found:
 */
            __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
            PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_93));
            __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
            __Pyx_INCREF(__pyx_v_self->logfile);
            PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->logfile);
            __Pyx_GIVEREF(__pyx_v_self->logfile);
            __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1406:                             break
            /* "water_algorithm_cython.pyx":1406
 *                             print_(wo_2, self.logfile)
 *                             print_("---", self.logfile)
 *                             break             # <<<<<<<<<<<<<<
 *                     if symmetry_found:
 *                         break
 */
            goto __pyx_L17_break;
            goto __pyx_L18;
          }
          __pyx_L18:;
        }
        __pyx_L17_break:;
 1407:                     if symmetry_found:
        /* "water_algorithm_cython.pyx":1407
 *                             print_("---", self.logfile)
 *                             break
 *                     if symmetry_found:             # <<<<<<<<<<<<<<
 *                         break
 *                 if symmetry_found or copy_found:
 */
        if (__pyx_v_symmetry_found) {
 1408:                         break
          /* "water_algorithm_cython.pyx":1408
 *                             break
 *                     if symmetry_found:
 *                         break             # <<<<<<<<<<<<<<
 *                 if symmetry_found or copy_found:
 *                     break
 */
          goto __pyx_L15_break;
          goto __pyx_L19;
        }
        __pyx_L19:;
      }
      __pyx_L15_break:;
 1409:                 if symmetry_found or copy_found:
      /* "water_algorithm_cython.pyx":1409
 *                     if symmetry_found:
 *                         break
 *                 if symmetry_found or copy_found:             # <<<<<<<<<<<<<<
 *                     break
 *                 self_symmetry_found = np.all(np.equal(wo, symmetry))
 */
      if (!__pyx_v_symmetry_found) {
        __pyx_t_8 = __pyx_v_copy_found;
      } else {
        __pyx_t_8 = __pyx_v_symmetry_found;
      }
      if (__pyx_t_8) {
 1410:                     break
        /* "water_algorithm_cython.pyx":1410
 *                         break
 *                 if symmetry_found or copy_found:
 *                     break             # <<<<<<<<<<<<<<
 *                 self_symmetry_found = np.all(np.equal(wo, symmetry))
 *                 if save_self_symmetry_groups and self_symmetry_found:
 */
        goto __pyx_L7_break;
        goto __pyx_L20;
      }
      __pyx_L20:;
 1411:                 self_symmetry_found = np.all(np.equal(wo, symmetry))
      /* "water_algorithm_cython.pyx":1411
 *                 if symmetry_found or copy_found:
 *                     break
 *                 self_symmetry_found = np.all(np.equal(wo, symmetry))             # <<<<<<<<<<<<<<
 *                 if save_self_symmetry_groups and self_symmetry_found:
 *                     print_("SELF SYMMETRY FOUND", self.logfile)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__all); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__equal); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_wo));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_wo));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
      __Pyx_INCREF(((PyObject *)__pyx_v_symmetry));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_symmetry));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry));
      __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_18 = __Pyx_PyInt_from_py_npy_int8(__pyx_t_5); if (unlikely((__pyx_t_18 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_self_symmetry_found = __pyx_t_18;
 1412:                 if save_self_symmetry_groups and self_symmetry_found:
      /* "water_algorithm_cython.pyx":1412
 *                     break
 *                 self_symmetry_found = np.all(np.equal(wo, symmetry))
 *                 if save_self_symmetry_groups and self_symmetry_found:             # <<<<<<<<<<<<<<
 *                     print_("SELF SYMMETRY FOUND", self.logfile)
 *                     print_(symmetry_operation.nn_change_matrix, self.logfile)
 */
      __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_save_self_symmetry_groups)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_8) {
        __pyx_t_20 = __pyx_v_self_symmetry_found;
      } else {
        __pyx_t_20 = __pyx_t_8;
      }
      if (__pyx_t_20) {
 1413:                     print_("SELF SYMMETRY FOUND", self.logfile)
        /* "water_algorithm_cython.pyx":1413
 *                 self_symmetry_found = np.all(np.equal(wo, symmetry))
 *                 if save_self_symmetry_groups and self_symmetry_found:
 *                     print_("SELF SYMMETRY FOUND", self.logfile)             # <<<<<<<<<<<<<<
 *                     print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                     print_(symmetry_operation, self.logfile)
 */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_95));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_95));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_95));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1414:                     print_(symmetry_operation.nn_change_matrix, self.logfile)
        /* "water_algorithm_cython.pyx":1414
 *                 if save_self_symmetry_groups and self_symmetry_found:
 *                     print_("SELF SYMMETRY FOUND", self.logfile)
 *                     print_(symmetry_operation.nn_change_matrix, self.logfile)             # <<<<<<<<<<<<<<
 *                     print_(symmetry_operation, self.logfile)
 *                     print_(wo, self.logfile)
 */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1415:                     print_(symmetry_operation, self.logfile)
        /* "water_algorithm_cython.pyx":1415
 *                     print_("SELF SYMMETRY FOUND", self.logfile)
 *                     print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                     print_(symmetry_operation, self.logfile)             # <<<<<<<<<<<<<<
 *                     print_(wo, self.logfile)
 *                     print_("---", self.logfile)
 */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_symmetry_operation));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_symmetry_operation));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_symmetry_operation));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1416:                     print_(wo, self.logfile)
        /* "water_algorithm_cython.pyx":1416
 *                     print_(symmetry_operation.nn_change_matrix, self.logfile)
 *                     print_(symmetry_operation, self.logfile)
 *                     print_(wo, self.logfile)             # <<<<<<<<<<<<<<
 *                     print_("---", self.logfile)
 *                     self_symmetry_operations.append(symmetry_operation)
 */
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_v_wo));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_wo));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1417:                     print_("---", self.logfile)
        /* "water_algorithm_cython.pyx":1417
 *                     print_(symmetry_operation, self.logfile)
 *                     print_(wo, self.logfile)
 *                     print_("---", self.logfile)             # <<<<<<<<<<<<<<
 *                     self_symmetry_operations.append(symmetry_operation)
 *             if not symmetry_found and len(self_symmetry_operations) > 0:
 */
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(((PyObject *)__pyx_kp_s_93));
        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_93));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_93));
        __Pyx_INCREF(__pyx_v_self->logfile);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->logfile);
        __Pyx_GIVEREF(__pyx_v_self->logfile);
        __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1418:                     self_symmetry_operations.append(symmetry_operation)
        /* "water_algorithm_cython.pyx":1418
 *                     print_(wo, self.logfile)
 *                     print_("---", self.logfile)
 *                     self_symmetry_operations.append(symmetry_operation)             # <<<<<<<<<<<<<<
 *             if not symmetry_found and len(self_symmetry_operations) > 0:
 *                 new_self_symmetry_groups.append(SelfSymmetryGroup(self_symmetry_operations, wo, None))
 */
        __pyx_t_21 = __Pyx_PyList_Append(__pyx_v_self_symmetry_operations, ((PyObject *)__pyx_v_symmetry_operation)); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L21;
      }
      __pyx_L21:;
    }
    __pyx_L7_break:;
 1419:             if not symmetry_found and len(self_symmetry_operations) > 0:
    /* "water_algorithm_cython.pyx":1419
 *                     print_("---", self.logfile)
 *                     self_symmetry_operations.append(symmetry_operation)
 *             if not symmetry_found and len(self_symmetry_operations) > 0:             # <<<<<<<<<<<<<<
 *                 new_self_symmetry_groups.append(SelfSymmetryGroup(self_symmetry_operations, wo, None))
 *             elif not  symmetry_found:
 */
    __pyx_t_20 = (!__pyx_v_symmetry_found);
    if (__pyx_t_20) {
      __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_self_symmetry_operations)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = (__pyx_t_1 > 0);
      __pyx_t_22 = __pyx_t_8;
    } else {
      __pyx_t_22 = __pyx_t_20;
    }
    if (__pyx_t_22) {
 1420:                 new_self_symmetry_groups.append(SelfSymmetryGroup(self_symmetry_operations, wo, None))
      /* "water_algorithm_cython.pyx":1420
 *                     self_symmetry_operations.append(symmetry_operation)
 *             if not symmetry_found and len(self_symmetry_operations) > 0:
 *                 new_self_symmetry_groups.append(SelfSymmetryGroup(self_symmetry_operations, wo, None))             # <<<<<<<<<<<<<<
 *             elif not  symmetry_found:
 *                 results = np.vstack((results, wo))
 */
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_v_self_symmetry_operations));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self_symmetry_operations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self_symmetry_operations));
      __Pyx_INCREF(((PyObject *)__pyx_v_wo));
      PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_wo));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
      __Pyx_INCREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup)), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_t_21 = __Pyx_PyList_Append(__pyx_v_new_self_symmetry_groups, __pyx_t_2); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L22;
    }
 1421:             elif not  symmetry_found:
    /* "water_algorithm_cython.pyx":1421
 *             if not symmetry_found and len(self_symmetry_operations) > 0:
 *                 new_self_symmetry_groups.append(SelfSymmetryGroup(self_symmetry_operations, wo, None))
 *             elif not  symmetry_found:             # <<<<<<<<<<<<<<
 *                 results = np.vstack((results, wo))
 *         self_symmetry_groups.extend(new_self_symmetry_groups)
 */
    __pyx_t_22 = (!__pyx_v_symmetry_found);
    if (__pyx_t_22) {
 1422:                 results = np.vstack((results, wo))
      /* "water_algorithm_cython.pyx":1422
 *                 new_self_symmetry_groups.append(SelfSymmetryGroup(self_symmetry_operations, wo, None))
 *             elif not  symmetry_found:
 *                 results = np.vstack((results, wo))             # <<<<<<<<<<<<<<
 *         self_symmetry_groups.extend(new_self_symmetry_groups)
 *         print_parallel("  -Removed  %i geometries due to symmetry" % (length_before-results.shape[0]), self.logfile)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__vstack); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_results));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_results));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_results));
      __Pyx_INCREF(((PyObject *)__pyx_v_wo));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_wo));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_wo));
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
        __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_10 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_results.rcbuffer->pybuffer, (PyObject*)__pyx_v_results, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          }
        }
        __pyx_pybuffernd_results.diminfo[0].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_results.diminfo[0].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_results.diminfo[1].strides = __pyx_pybuffernd_results.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_results.diminfo[1].shape = __pyx_pybuffernd_results.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_results));
      __pyx_v_results = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      goto __pyx_L22;
    }
    __pyx_L22:;
  }
 1423:         self_symmetry_groups.extend(new_self_symmetry_groups)
  /* "water_algorithm_cython.pyx":1423
 *             elif not  symmetry_found:
 *                 results = np.vstack((results, wo))
 *         self_symmetry_groups.extend(new_self_symmetry_groups)             # <<<<<<<<<<<<<<
 *         print_parallel("  -Removed  %i geometries due to symmetry" % (length_before-results.shape[0]), self.logfile)
 *         print_parallel("  -Finally %i geometries" % results.shape[0], self.logfile)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self_symmetry_groups), __pyx_n_s__extend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_new_self_symmetry_groups));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_new_self_symmetry_groups));
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1424:         print_parallel("  -Removed  %i geometries due to symmetry" % (length_before-results.shape[0]), self.logfile)
  /* "water_algorithm_cython.pyx":1424
 *                 results = np.vstack((results, wo))
 *         self_symmetry_groups.extend(new_self_symmetry_groups)
 *         print_parallel("  -Removed  %i geometries due to symmetry" % (length_before-results.shape[0]), self.logfile)             # <<<<<<<<<<<<<<
 *         print_parallel("  -Finally %i geometries" % results.shape[0], self.logfile)
 *         return results
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyInt_FromLong((__pyx_v_length_before - (__pyx_v_results->dimensions[0]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_96), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self->logfile);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->logfile);
  __Pyx_GIVEREF(__pyx_v_self->logfile);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1425:         print_parallel("  -Finally %i geometries" % results.shape[0], self.logfile)
  /* "water_algorithm_cython.pyx":1425
 *         self_symmetry_groups.extend(new_self_symmetry_groups)
 *         print_parallel("  -Removed  %i geometries due to symmetry" % (length_before-results.shape[0]), self.logfile)
 *         print_parallel("  -Finally %i geometries" % results.shape[0], self.logfile)             # <<<<<<<<<<<<<<
 *         return results
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_parallel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyInt_to_py_Py_intptr_t((__pyx_v_results->dimensions[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_97), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __Pyx_INCREF(__pyx_v_self->logfile);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->logfile);
  __Pyx_GIVEREF(__pyx_v_self->logfile);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1426:         return results
  /* "water_algorithm_cython.pyx":1426
 *         print_parallel("  -Removed  %i geometries due to symmetry" % (length_before-results.shape[0]), self.logfile)
 *         print_parallel("  -Finally %i geometries" % results.shape[0], self.logfile)
 *         return results             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_results));
  __pyx_r = ((PyArrayObject *)__pyx_v_results);
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.remove_symmetries_no_invariants", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_results.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_symmetry.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo_2.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_results);
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry);
  __Pyx_XDECREF((PyObject *)__pyx_v_wo);
  __Pyx_XDECREF((PyObject *)__pyx_v_wo_2);
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry_operation);
  __Pyx_XDECREF(__pyx_v_self_symmetry_operations);
  __Pyx_XDECREF((PyObject *)__pyx_v_self_symmetry_group);
  __Pyx_XDECREF(__pyx_v_new_self_symmetry_groups);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1427: 
 1428: 
 1429:     cdef bint is_symmetric_with_another_result(self, ResultGroup result_group, DTYPE2_t[::1] water_orientations, signed int current_no, bint find_single, list symmetry_operations, int result_group_level, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, DTYPE2_t[:, ::1] bond_variables):
/* "water_algorithm_cython.pyx":1429
 * 
 * 
 *     cdef bint is_symmetric_with_another_result(self, ResultGroup result_group, DTYPE2_t[::1] water_orientations, signed int current_no, bint find_single, list symmetry_operations, int result_group_level, list self_symmetry_groups, bint save_self_symmetry_groups, list pending_self_symmetry_operations, SelfSymmetryGroup parent_self_symmetry_group, DTYPE2_t[:, ::1] bond_variables):             # <<<<<<<<<<<<<<
 *         """
 *             Checks if water orientation list is symmetric with some other water orientation list.
 */

static int __pyx_f_22water_algorithm_cython_14WaterAlgorithm_is_symmetric_with_another_result(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_result_group, __Pyx_memviewslice __pyx_v_water_orientations, CYTHON_UNUSED signed int __pyx_v_current_no, CYTHON_UNUSED int __pyx_v_find_single, PyObject *__pyx_v_symmetry_operations, int __pyx_v_result_group_level, PyObject *__pyx_v_self_symmetry_groups, int __pyx_v_save_self_symmetry_groups, PyObject *__pyx_v_pending_self_symmetry_operations, CYTHON_UNUSED struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *__pyx_v_parent_self_symmetry_group, __Pyx_memviewslice __pyx_v_bond_variables) {
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_N;
  unsigned int __pyx_v_M;
  unsigned int __pyx_v_O;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_are_symmetric;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_is_self_symmetric;
  PyArrayObject *__pyx_v_nearest_neighbors_nos = 0;
  PyObject *__pyx_v_s = NULL;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_res_group = 0;
  PyObject *__pyx_v_self_symmetries = 0;
  __Pyx_memviewslice __pyx_v_symmetry = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_wator = { 0, 0, { 0 }, { 0 }, { 0 } };
  struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *__pyx_v_symmetry_operation = 0;
  __Pyx_memviewslice __pyx_v_wos = { 0, 0, { 0 }, { 0 }, { 0 } };
  struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_wa = 0;
  int __pyx_v_inverse;
  PyArrayObject *__pyx_v_wo_base = 0;
  long __pyx_v_n;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nearest_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_nearest_neighbors_nos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_wo_base;
  __Pyx_Buffer __pyx_pybuffer_wo_base;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_symmetric_with_another_result", 0);
  __pyx_pybuffer_nearest_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_nearest_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_nearest_neighbors_nos.data = NULL;
  __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer = &__pyx_pybuffer_nearest_neighbors_nos;
  __pyx_pybuffer_wo_base.pybuffer.buf = NULL;
  __pyx_pybuffer_wo_base.refcount = 0;
  __pyx_pybuffernd_wo_base.data = NULL;
  __pyx_pybuffernd_wo_base.rcbuffer = &__pyx_pybuffer_wo_base;
 1430:         """
 1431:             Checks if water orientation list is symmetric with some other water orientation list.
 1432:             The process is initialized by getting the bond variables which are used in getting the
 1433:             corrent result group, which contains the possible combinations for symmetric orientation
 1434:             list. After this the water orientations symmetricity is compared agaist the members of this
 1435:             group and added to the group if no symmetric result is found.
 1436:                 The method also finds the self symmetric results and initializes the SelfSymmetryGroup
 1437:             objects required in the handling of children.
 1438: 
 1439:             Parameters:
 1440:                 result_group                    : the initial result group which contains the currentry handled waterorientation list grouped to a certain level
 1441:                 water_orientations              : the currently handled water orientation list
 1442:                 current_no                      : the number of the molecule currently handled
 1443:                 find_single                     : (DEPRECATED) set to False
 1444:                 symmetry_operations             : the list of SymmetryOperation objects checked
 1445:                 result_group_level              : the level the result groups are checked to
 1446:                 self_symmetry_groups            : the list containing all SelfSymmetryGroup objects and in which to new instances are added
 1447:                 save_self_symmetry_groups       : if the self symmetry groups are saved in the process
 1448:                 pending_self_symmetry_operations: the symmetry operations that are pending for all the newly found self symmetry groups
 1449:                 parent_self_symmetry_group      : the parent self symmetry group for all newly found self symmetry groups
 1450:                 bond_variables                  : just an empty bond_variables table (goes with because of execution speed)
 1451: 
 1452:             Returns
 1453:                 0 if symmetries are not found
 1454:                 1 if a symmetry is found, or if self symmetry is found and save_self_symmetry_groups is True
 1455: 
 1456: 
 1457:         """
 1458:         cdef unsigned int i, N, M = len(symmetry_operations), O = water_orientations.shape[0]
  /* "water_algorithm_cython.pyx":1458
 * 
 *         """
 *         cdef unsigned int i, N, M = len(symmetry_operations), O = water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *         cdef DTYPE_t are_symmetric, is_self_symmetric
 *         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = <np.ndarray[DTYPE_t, ndim=3]> self.nearest_neighbors_nos
 */
  if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_symmetry_operations)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_M = __pyx_t_1;
  __pyx_v_O = (__pyx_v_water_orientations.shape[0]);
 1459:         cdef DTYPE_t are_symmetric, is_self_symmetric
 1460:         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = <np.ndarray[DTYPE_t, ndim=3]> self.nearest_neighbors_nos
  /* "water_algorithm_cython.pyx":1460
 *         cdef unsigned int i, N, M = len(symmetry_operations), O = water_orientations.shape[0]
 *         cdef DTYPE_t are_symmetric, is_self_symmetric
 *         cdef np.ndarray[DTYPE_t, ndim=3] nearest_neighbors_nos = <np.ndarray[DTYPE_t, ndim=3]> self.nearest_neighbors_nos             # <<<<<<<<<<<<<<
 *         #if current_no != -1 and result_group.bvs is not None and len(result_group.bvs) > 0:
 *         #    bond_variables = result_group.bvs[current_no]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_nearest_neighbors_nos = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_3 = 0;
  __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_t_2)));
  __pyx_v_nearest_neighbors_nos = ((PyArrayObject *)__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1461:         #if current_no != -1 and result_group.bvs is not None and len(result_group.bvs) > 0:
 1462:         #    bond_variables = result_group.bvs[current_no]
 1463:         #else:
 1464:         s = time()
  /* "water_algorithm_cython.pyx":1464
 *         #    bond_variables = result_group.bvs[current_no]
 *         #else:
 *         s = time()             # <<<<<<<<<<<<<<
 *         get_bond_variables_3(water_orientations,  nearest_neighbors_nos, O, bond_variables)
 *         self.conversion_time += time() - s
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_s = __pyx_t_4;
  __pyx_t_4 = 0;
 1465:         get_bond_variables_3(water_orientations,  nearest_neighbors_nos, O, bond_variables)
  /* "water_algorithm_cython.pyx":1465
 *         #else:
 *         s = time()
 *         get_bond_variables_3(water_orientations,  nearest_neighbors_nos, O, bond_variables)             # <<<<<<<<<<<<<<
 *         self.conversion_time += time() - s
 *         # Find the result group
 */
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(((PyObject *)__pyx_v_nearest_neighbors_nos));
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_v_water_orientations, __pyx_t_5, __pyx_v_O, __pyx_v_bond_variables);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
 1466:         self.conversion_time += time() - s
  /* "water_algorithm_cython.pyx":1466
 *         s = time()
 *         get_bond_variables_3(water_orientations,  nearest_neighbors_nos, O, bond_variables)
 *         self.conversion_time += time() - s             # <<<<<<<<<<<<<<
 *         # Find the result group
 *         s = time()
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_6, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 1467:         # Find the result group
 1468:         s = time()
  /* "water_algorithm_cython.pyx":1468
 *         self.conversion_time += time() - s
 *         # Find the result group
 *         s = time()             # <<<<<<<<<<<<<<
 *         cdef ResultGroup res_group = result_group._try_subgroups(<np.ndarray[DTYPE2_t, ndim=2]>bond_variables.base, result_group_level)
 *         self.result_group_tryout_time += time()-s
 */
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_v_s);
  __pyx_v_s = __pyx_t_2;
  __pyx_t_2 = 0;
 1469:         cdef ResultGroup res_group = result_group._try_subgroups(<np.ndarray[DTYPE2_t, ndim=2]>bond_variables.base, result_group_level)
  /* "water_algorithm_cython.pyx":1469
 *         # Find the result group
 *         s = time()
 *         cdef ResultGroup res_group = result_group._try_subgroups(<np.ndarray[DTYPE2_t, ndim=2]>bond_variables.base, result_group_level)             # <<<<<<<<<<<<<<
 *         self.result_group_tryout_time += time()-s
 *         cdef list self_symmetries = []
 */
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_bond_variables, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__base); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(__pyx_t_6);
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_result_group->__pyx_vtab)->_try_subgroups(__pyx_v_result_group, __pyx_t_7, __pyx_v_result_group_level)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __pyx_v_res_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_6);
  __pyx_t_6 = 0;
 1470:         self.result_group_tryout_time += time()-s
  /* "water_algorithm_cython.pyx":1470
 *         s = time()
 *         cdef ResultGroup res_group = result_group._try_subgroups(<np.ndarray[DTYPE2_t, ndim=2]>bond_variables.base, result_group_level)
 *         self.result_group_tryout_time += time()-s             # <<<<<<<<<<<<<<
 *         cdef list self_symmetries = []
 *         cdef DTYPE2_t[::1] symmetry
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_29); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_4, __pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_29, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1471:         cdef list self_symmetries = []
  /* "water_algorithm_cython.pyx":1471
 *         cdef ResultGroup res_group = result_group._try_subgroups(<np.ndarray[DTYPE2_t, ndim=2]>bond_variables.base, result_group_level)
 *         self.result_group_tryout_time += time()-s
 *         cdef list self_symmetries = []             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] symmetry
 *         cdef DTYPE2_t[::1] wator
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_self_symmetries = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;
 1472:         cdef DTYPE2_t[::1] symmetry
 1473:         cdef DTYPE2_t[::1] wator
 1474: 
 1475:         #print "Result group has %i results" % len(res_group.wos)
 1476:         # Load symmetries only if there are other results to be checked with
 1477:         #if res_group.get_wos() != None and len(res_group.get_wos()) >0:
 1478:         #    #print "Result group has %i water orientations" % len(res_group.get_wos())
 1479:         #    symmetries = self.get_symmetries(water_orientations, nearest_neighbors_nos, symmetry_operations)
 1480:         #
 1481:         #    self.symmetries_loaded += 1
 1482:         #    #print "Symmetry Load %i" % *symmetries_loaded
 1483:         #    M = symmetries.shape[0]
 1484:         #s = time()
 1485: 
 1486:         cdef SymmetryOperation symmetry_operation
 1487:         # go through all water orientations with same invariant values
 1488:         #  in other words all water orientations that belong to same group
 1489:         #if res_group.wos is not None and len(res_group.get_wos()) >0:
 1490:         #self.symmetries_loaded += 1
 1491:         cdef DTYPE2_t[:, ::1] wos =  res_group.get_wos()
  /* "water_algorithm_cython.pyx":1491
 *         #if res_group.wos is not None and len(res_group.get_wos()) >0:
 *         #self.symmetries_loaded += 1
 *         cdef DTYPE2_t[:, ::1] wos =  res_group.get_wos()             # <<<<<<<<<<<<<<
 *         cdef WaterAlgorithm wa = self
 *         if wos is None:
 */
  __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_res_group->__pyx_vtab)->get_wos(__pyx_v_res_group)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
  if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_wos = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 1492:         cdef WaterAlgorithm wa = self
  /* "water_algorithm_cython.pyx":1492
 *         #self.symmetries_loaded += 1
 *         cdef DTYPE2_t[:, ::1] wos =  res_group.get_wos()
 *         cdef WaterAlgorithm wa = self             # <<<<<<<<<<<<<<
 *         if wos is None:
 *             N = 0
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_v_wa = __pyx_v_self;
 1493:         if wos is None:
  /* "water_algorithm_cython.pyx":1493
 *         cdef DTYPE2_t[:, ::1] wos =  res_group.get_wos()
 *         cdef WaterAlgorithm wa = self
 *         if wos is None:             # <<<<<<<<<<<<<<
 *             N = 0
 *         else:
 */
  __pyx_t_9 = (((PyObject *) __pyx_v_wos.memview) == Py_None);
  if (__pyx_t_9) {
 1494:             N = 0
    /* "water_algorithm_cython.pyx":1494
 *         cdef WaterAlgorithm wa = self
 *         if wos is None:
 *             N = 0             # <<<<<<<<<<<<<<
 *         else:
 *             N = wos.shape[0]
 */
    __pyx_v_N = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 1495:         else:
 1496:             N = wos.shape[0]
    /* "water_algorithm_cython.pyx":1496
 *             N = 0
 *         else:
 *             N = wos.shape[0]             # <<<<<<<<<<<<<<
 *         cdef bint inverse = False
 *         cdef np.ndarray[DTYPE2_t, ndim = 1] wo_base = water_orientations.base
 */
    __pyx_v_N = (__pyx_v_wos.shape[0]);
  }
  __pyx_L3:;
 1497:         cdef bint inverse = False
  /* "water_algorithm_cython.pyx":1497
 *         else:
 *             N = wos.shape[0]
 *         cdef bint inverse = False             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE2_t, ndim = 1] wo_base = water_orientations.base
 * 
 */
  __pyx_v_inverse = 0;
 1498:         cdef np.ndarray[DTYPE2_t, ndim = 1] wo_base = water_orientations.base
  /* "water_algorithm_cython.pyx":1498
 *             N = wos.shape[0]
 *         cdef bint inverse = False
 *         cdef np.ndarray[DTYPE2_t, ndim = 1] wo_base = water_orientations.base             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_wo_base.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_wo_base = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_wo_base.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_wo_base.diminfo[0].strides = __pyx_pybuffernd_wo_base.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_wo_base.diminfo[0].shape = __pyx_pybuffernd_wo_base.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_10 = 0;
  __pyx_v_wo_base = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 1499: 
 1500: 
 1501: 
 1502:         if  save_self_symmetry_groups or N != 0:
  /* "water_algorithm_cython.pyx":1502
 * 
 * 
 *         if  save_self_symmetry_groups or N != 0:             # <<<<<<<<<<<<<<
 * 
 *             for n from 0 <= n < M:
 */
  if (!__pyx_v_save_self_symmetry_groups) {
    __pyx_t_9 = (__pyx_v_N != 0);
    __pyx_t_11 = __pyx_t_9;
  } else {
    __pyx_t_11 = __pyx_v_save_self_symmetry_groups;
  }
  if (__pyx_t_11) {
 1503: 
 1504:             for n from 0 <= n < M:
    /* "water_algorithm_cython.pyx":1504
 *         if  save_self_symmetry_groups or N != 0:
 * 
 *             for n from 0 <= n < M:             # <<<<<<<<<<<<<<
 *                 s = time()
 *                 symmetry_operation = <SymmetryOperation>symmetry_operations[n]
 */
    __pyx_t_12 = __pyx_v_M;
    for (__pyx_v_n = 0; __pyx_v_n < __pyx_t_12; __pyx_v_n++) {
 1505:                 s = time()
      /* "water_algorithm_cython.pyx":1505
 * 
 *             for n from 0 <= n < M:
 *                 s = time()             # <<<<<<<<<<<<<<
 *                 symmetry_operation = <SymmetryOperation>symmetry_operations[n]
 *                 if symmetry_operation.type == <bytes> 'E':
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_t_4;
      __pyx_t_4 = 0;
 1506:                 symmetry_operation = <SymmetryOperation>symmetry_operations[n]
      /* "water_algorithm_cython.pyx":1506
 *             for n from 0 <= n < M:
 *                 s = time()
 *                 symmetry_operation = <SymmetryOperation>symmetry_operations[n]             # <<<<<<<<<<<<<<
 *                 if symmetry_operation.type == <bytes> 'E':
 *                     continue
 */
      if (unlikely(((PyObject *)__pyx_v_symmetry_operations) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = PyList_GET_ITEM(__pyx_v_symmetry_operations, __pyx_v_n);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry_operation));
      __pyx_v_symmetry_operation = ((struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_t_4);
      __pyx_t_4 = 0;
 1507:                 if symmetry_operation.type == <bytes> 'E':
      /* "water_algorithm_cython.pyx":1507
 *                 s = time()
 *                 symmetry_operation = <SymmetryOperation>symmetry_operations[n]
 *                 if symmetry_operation.type == <bytes> 'E':             # <<<<<<<<<<<<<<
 *                     continue
 * 
 */
      __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_symmetry_operation->type); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_t_4), ((PyObject *)__pyx_n_s__E), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_11) {
 1508:                     continue
        /* "water_algorithm_cython.pyx":1508
 *                 symmetry_operation = <SymmetryOperation>symmetry_operations[n]
 *                 if symmetry_operation.type == <bytes> 'E':
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 symmetry = symmetry_operation.apply(wo_base,  wa, nearest_neighbors_nos, inverse)
 */
        goto __pyx_L5_continue;
        goto __pyx_L7;
      }
      __pyx_L7:;
 1509: 
 1510:                 symmetry = symmetry_operation.apply(wo_base,  wa, nearest_neighbors_nos, inverse)
      /* "water_algorithm_cython.pyx":1510
 *                     continue
 * 
 *                 symmetry = symmetry_operation.apply(wo_base,  wa, nearest_neighbors_nos, inverse)             # <<<<<<<<<<<<<<
 * 
 *                 self.symmetry_load_time += time()-s
 */
      __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE2_t(((PyObject *)__pyx_v_wo_base));
      if (unlikely(!__pyx_t_13.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE_t(((PyObject *)__pyx_v_nearest_neighbors_nos));
      if (unlikely(!__pyx_t_14.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_v_symmetry_operation->__pyx_vtab)->apply(__pyx_v_symmetry_operation, __pyx_t_13, __pyx_v_wa, __pyx_t_14, __pyx_v_inverse)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
      __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_2);
      if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_symmetry, 1);
      __pyx_v_symmetry = __pyx_t_15;
      __pyx_t_15.memview = NULL;
      __pyx_t_15.data = NULL;
 1511: 
 1512:                 self.symmetry_load_time += time()-s
      /* "water_algorithm_cython.pyx":1512
 *                 symmetry = symmetry_operation.apply(wo_base,  wa, nearest_neighbors_nos, inverse)
 * 
 *                 self.symmetry_load_time += time()-s             # <<<<<<<<<<<<<<
 *                 s = time()
 *                 for i from 0 <= i < N:
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_load_time); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Subtract(__pyx_t_6, __pyx_v_s); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_load_time, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 1513:                 s = time()
      /* "water_algorithm_cython.pyx":1513
 * 
 *                 self.symmetry_load_time += time()-s
 *                 s = time()             # <<<<<<<<<<<<<<
 *                 for i from 0 <= i < N:
 *                     wator = wos[i]
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_s);
      __pyx_v_s = __pyx_t_4;
      __pyx_t_4 = 0;
 1514:                 for i from 0 <= i < N:
      /* "water_algorithm_cython.pyx":1514
 *                 self.symmetry_load_time += time()-s
 *                 s = time()
 *                 for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *                     wator = wos[i]
 *                     are_symmetric = wos_are_equal(wator, symmetry, O) # np.all(np.equal(wator, symmetry)) #
 */
      __pyx_t_16 = __pyx_v_N;
      for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_16; __pyx_v_i++) {
 1515:                     wator = wos[i]
        /* "water_algorithm_cython.pyx":1515
 *                 s = time()
 *                 for i from 0 <= i < N:
 *                     wator = wos[i]             # <<<<<<<<<<<<<<
 *                     are_symmetric = wos_are_equal(wator, symmetry, O) # np.all(np.equal(wator, symmetry)) #
 *                     if are_symmetric:
 */
        __pyx_t_18 = -1;
        __pyx_t_17.data = __pyx_v_wos.data;
        __pyx_t_17.memview = __pyx_v_wos.memview;
        __PYX_INC_MEMVIEW(&__pyx_t_17, 0);
        {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_wos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_wos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_17.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_17.shape[0] = __pyx_v_wos.shape[1];
__pyx_t_17.strides[0] = __pyx_v_wos.strides[1];
    __pyx_t_17.suboffsets[0] = -1;

__PYX_XDEC_MEMVIEW(&__pyx_v_wator, 1);
        __pyx_v_wator = __pyx_t_17;
        __pyx_t_17.memview = NULL;
        __pyx_t_17.data = NULL;
 1516:                     are_symmetric = wos_are_equal(wator, symmetry, O) # np.all(np.equal(wator, symmetry)) #
        /* "water_algorithm_cython.pyx":1516
 *                 for i from 0 <= i < N:
 *                     wator = wos[i]
 *                     are_symmetric = wos_are_equal(wator, symmetry, O) # np.all(np.equal(wator, symmetry)) #             # <<<<<<<<<<<<<<
 *                     if are_symmetric:
 *                         #print_("SYMMETRY FOUND ", self.logfile)
 */
        __pyx_v_are_symmetric = __pyx_f_22water_algorithm_cython_wos_are_equal(__pyx_v_wator, __pyx_v_symmetry, __pyx_v_O);
 1517:                     if are_symmetric:
        /* "water_algorithm_cython.pyx":1517
 *                     wator = wos[i]
 *                     are_symmetric = wos_are_equal(wator, symmetry, O) # np.all(np.equal(wator, symmetry)) #
 *                     if are_symmetric:             # <<<<<<<<<<<<<<
 *                         #print_("SYMMETRY FOUND ", self.logfile)
 *                         #print_("%s" % symmetry_operation.molecule_change_matrix, self.logfile)
 */
        if (__pyx_v_are_symmetric) {
 1518:                         #print_("SYMMETRY FOUND ", self.logfile)
 1519:                         #print_("%s" % symmetry_operation.molecule_change_matrix, self.logfile)
 1520:                         #print_(symmetry_operation.nn_change_matrix, self.logfile)
 1521:                         #self.view_result(water_orientations)
 1522:                         #self.view_result(wator)
 1523:                         #if np.all(np.equal(water_orientations, symmetry)):
 1524:                         #    print "They are equal, should not be"
 1525:                         #    raw_input()
 1526:                         #print_(water_orientations.base, self.logfile)
 1527:                         #print_(wator, self.logfile)
 1528:                         #print_(symmetry, self.logfile)
 1529:                         #print wator
 1530:                         #print self.nearest_neighbors_nos
 1531:                         #raw_input()
 1532:                         #symmetry_operation.found_earlier = True
 1533:                         #self.symmetry_check_time += time()-s
 1534:                         #if find_single:
 1535:                         #    return wator
 1536:                         return True
          /* "water_algorithm_cython.pyx":1536
 *                         #if find_single:
 *                         #    return wator
 *                         return True             # <<<<<<<<<<<<<<
 *                 is_self_symmetric =  wos_are_equal(water_orientations, symmetry, O) # np.all(np.equal(water_orientations, symmetry)) #
 *                 if save_self_symmetry_groups and is_self_symmetric:
 */
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L10;
        }
        __pyx_L10:;
      }
 1537:                 is_self_symmetric =  wos_are_equal(water_orientations, symmetry, O) # np.all(np.equal(water_orientations, symmetry)) #
      /* "water_algorithm_cython.pyx":1537
 *                         #    return wator
 *                         return True
 *                 is_self_symmetric =  wos_are_equal(water_orientations, symmetry, O) # np.all(np.equal(water_orientations, symmetry)) #             # <<<<<<<<<<<<<<
 *                 if save_self_symmetry_groups and is_self_symmetric:
 *                     #print_("SELF SYMMETRY FOUND", self.logfile)
 */
      __pyx_v_is_self_symmetric = __pyx_f_22water_algorithm_cython_wos_are_equal(__pyx_v_water_orientations, __pyx_v_symmetry, __pyx_v_O);
 1538:                 if save_self_symmetry_groups and is_self_symmetric:
      /* "water_algorithm_cython.pyx":1538
 *                         return True
 *                 is_self_symmetric =  wos_are_equal(water_orientations, symmetry, O) # np.all(np.equal(water_orientations, symmetry)) #
 *                 if save_self_symmetry_groups and is_self_symmetric:             # <<<<<<<<<<<<<<
 *                     #print_("SELF SYMMETRY FOUND", self.logfile)
 *                     #print_(symmetry_operation.molecule_change_matrix, self.logfile)
 */
      __pyx_t_11 = __pyx_v_save_self_symmetry_groups;
      if (__pyx_t_11) {
        __pyx_t_9 = __pyx_v_is_self_symmetric;
      } else {
        __pyx_t_9 = __pyx_t_11;
      }
      if (__pyx_t_9) {
 1539:                     #print_("SELF SYMMETRY FOUND", self.logfile)
 1540:                     #print_(symmetry_operation.molecule_change_matrix, self.logfile)
 1541:                     #print_(symmetry_operation, self.logfile)
 1542:                     #print_(water_orientations.base, self.logfile)
 1543:                     self_symmetries.append(symmetry_operation)
        /* "water_algorithm_cython.pyx":1543
 *                     #print_(symmetry_operation, self.logfile)
 *                     #print_(water_orientations.base, self.logfile)
 *                     self_symmetries.append(symmetry_operation)             # <<<<<<<<<<<<<<
 *                 self.symmetry_check_time += time()-s
 * 
 */
        __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_self_symmetries, ((PyObject *)__pyx_v_symmetry_operation)); if (unlikely(__pyx_t_19 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L11;
      }
      __pyx_L11:;
 1544:                 self.symmetry_check_time += time()-s
      /* "water_algorithm_cython.pyx":1544
 *                     #print_(water_orientations.base, self.logfile)
 *                     self_symmetries.append(symmetry_operation)
 *                 self.symmetry_check_time += time()-s             # <<<<<<<<<<<<<<
 * 
 *         res_group.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientations.base, None)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_check_time); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyNumber_Subtract(__pyx_t_2, __pyx_v_s); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__symmetry_check_time, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_L5_continue:;
    }
    goto __pyx_L4;
  }
  __pyx_L4:;
 1545: 
 1546:         res_group.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientations.base, None)
  /* "water_algorithm_cython.pyx":1546
 *                 self.symmetry_check_time += time()-s
 * 
 *         res_group.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientations.base, None)             # <<<<<<<<<<<<<<
 *         if save_self_symmetry_groups and  len(self_symmetries) > 0 and self_symmetry_groups is not None:
 *             if pending_self_symmetry_operations is not None:
 */
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__base); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_19result_group_cython_DTYPE2_t(Py_None);
  if (unlikely(!__pyx_t_20.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_res_group->__pyx_vtab)->add_result(__pyx_v_res_group, ((PyArrayObject *)__pyx_t_6), __pyx_t_20);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1);
 1547:         if save_self_symmetry_groups and  len(self_symmetries) > 0 and self_symmetry_groups is not None:
  /* "water_algorithm_cython.pyx":1547
 * 
 *         res_group.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientations.base, None)
 *         if save_self_symmetry_groups and  len(self_symmetries) > 0 and self_symmetry_groups is not None:             # <<<<<<<<<<<<<<
 *             if pending_self_symmetry_operations is not None:
 *                 self_symmetries.extend(pending_self_symmetry_operations)
 */
  if (__pyx_v_save_self_symmetry_groups) {
    __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_v_self_symmetries)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = (__pyx_t_1 > 0);
    if (__pyx_t_9) {
      __pyx_t_11 = (__pyx_v_self_symmetry_groups != ((PyObject*)Py_None));
      __pyx_t_21 = __pyx_t_11;
    } else {
      __pyx_t_21 = __pyx_t_9;
    }
    __pyx_t_9 = __pyx_t_21;
  } else {
    __pyx_t_9 = __pyx_v_save_self_symmetry_groups;
  }
  if (__pyx_t_9) {
 1548:             if pending_self_symmetry_operations is not None:
    /* "water_algorithm_cython.pyx":1548
 *         res_group.add_result(<np.ndarray[DTYPE2_t, ndim=1]>water_orientations.base, None)
 *         if save_self_symmetry_groups and  len(self_symmetries) > 0 and self_symmetry_groups is not None:
 *             if pending_self_symmetry_operations is not None:             # <<<<<<<<<<<<<<
 *                 self_symmetries.extend(pending_self_symmetry_operations)
 *             self_symmetry_groups.append(SelfSymmetryGroup(self_symmetries, <np.ndarray[DTYPE2_t, ndim=1]> water_orientations.base, None))
 */
    __pyx_t_9 = (__pyx_v_pending_self_symmetry_operations != ((PyObject*)Py_None));
    if (__pyx_t_9) {
 1549:                 self_symmetries.extend(pending_self_symmetry_operations)
      /* "water_algorithm_cython.pyx":1549
 *         if save_self_symmetry_groups and  len(self_symmetries) > 0 and self_symmetry_groups is not None:
 *             if pending_self_symmetry_operations is not None:
 *                 self_symmetries.extend(pending_self_symmetry_operations)             # <<<<<<<<<<<<<<
 *             self_symmetry_groups.append(SelfSymmetryGroup(self_symmetries, <np.ndarray[DTYPE2_t, ndim=1]> water_orientations.base, None))
 *             return True
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self_symmetries), __pyx_n_s__extend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(((PyObject *)__pyx_v_pending_self_symmetry_operations));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_pending_self_symmetry_operations));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_pending_self_symmetry_operations));
      __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L13;
    }
    __pyx_L13:;
 1550:             self_symmetry_groups.append(SelfSymmetryGroup(self_symmetries, <np.ndarray[DTYPE2_t, ndim=1]> water_orientations.base, None))
    /* "water_algorithm_cython.pyx":1550
 *             if pending_self_symmetry_operations is not None:
 *                 self_symmetries.extend(pending_self_symmetry_operations)
 *             self_symmetry_groups.append(SelfSymmetryGroup(self_symmetries, <np.ndarray[DTYPE2_t, ndim=1]> water_orientations.base, None))             # <<<<<<<<<<<<<<
 *             return True
 *         #if find_single:
 */
    if (unlikely(((PyObject *)__pyx_v_self_symmetry_groups) == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_self_symmetries));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self_symmetries));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self_symmetries));
    __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_t_2)));
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup)), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_self_symmetry_groups, __pyx_t_2); if (unlikely(__pyx_t_19 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1551:             return True
    /* "water_algorithm_cython.pyx":1551
 *                 self_symmetries.extend(pending_self_symmetry_operations)
 *             self_symmetry_groups.append(SelfSymmetryGroup(self_symmetries, <np.ndarray[DTYPE2_t, ndim=1]> water_orientations.base, None))
 *             return True             # <<<<<<<<<<<<<<
 *         #if find_single:
 *         #    return None
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;
 1552:         #if find_single:
 1553:         #    return None
 1554:         return False
  /* "water_algorithm_cython.pyx":1554
 *         #if find_single:
 *         #    return None
 *         return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __Pyx_XDECREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo_base.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("water_algorithm_cython.WaterAlgorithm.is_symmetric_with_another_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_wo_base.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_nearest_neighbors_nos);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF((PyObject *)__pyx_v_res_group);
  __Pyx_XDECREF(__pyx_v_self_symmetries);
  __PYX_XDEC_MEMVIEW(&__pyx_v_symmetry, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_wator, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry_operation);
  __PYX_XDEC_MEMVIEW(&__pyx_v_wos, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_wa);
  __Pyx_XDECREF((PyObject *)__pyx_v_wo_base);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_53finalize_grouping(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_22water_algorithm_cython_14WaterAlgorithm_52finalize_grouping[] = " Finalizes the initial grouping for given group made with do_initial_grouping ";
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_53finalize_grouping(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_group = 0;
  PyObject *__pyx_v_current_no = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("finalize_grouping (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__group,&__pyx_n_s__current_no,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__group)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__current_no);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "finalize_grouping") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_group = values[0];
    __pyx_v_current_no = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("finalize_grouping", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.finalize_grouping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_52finalize_grouping(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_group, __pyx_v_current_no);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1555: 
 1556: 
 1557: 
 1558:     def finalize_grouping(self, group, current_no = -1):
/* "water_algorithm_cython.pyx":1558
 * 
 * 
 *     def finalize_grouping(self, group, current_no = -1):             # <<<<<<<<<<<<<<
 *         """ Finalizes the initial grouping for given group made with do_initial_grouping """
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_52finalize_grouping(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_group, PyObject *__pyx_v_current_no) {
  __Pyx_memviewslice __pyx_v_bond_variables = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_wo = NULL;
  PyObject *__pyx_v_s = NULL;
  PyObject *__pyx_v_res_group = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("finalize_grouping", 0);
 1559:         """ Finalizes the initial grouping for given group made with do_initial_grouping """
 1560:         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":1560
 *     def finalize_grouping(self, group, current_no = -1):
 *         """ Finalizes the initial grouping for given group made with do_initial_grouping """
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         for wo in group.wos:
 *             if current_no != -1 and group.bvs != None and len(group.bvs) > 0:
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
  if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_bond_variables = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 1561:         for wo in group.wos:
  /* "water_algorithm_cython.pyx":1561
 *         """ Finalizes the initial grouping for given group made with do_initial_grouping """
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         for wo in group.wos:             # <<<<<<<<<<<<<<
 *             if current_no != -1 and group.bvs != None and len(group.bvs) > 0:
 *                 bond_variables = group.bvs[current_no]
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_group, __pyx_n_s__wos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF(__pyx_v_wo);
    __pyx_v_wo = __pyx_t_3;
    __pyx_t_3 = 0;
 1562:             if current_no != -1 and group.bvs != None and len(group.bvs) > 0:
    /* "water_algorithm_cython.pyx":1562
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         for wo in group.wos:
 *             if current_no != -1 and group.bvs != None and len(group.bvs) > 0:             # <<<<<<<<<<<<<<
 *                 bond_variables = group.bvs[current_no]
 *             else:
 */
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_current_no, __pyx_int_neg_1, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_group, __pyx_n_s__bvs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_8) {
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_group, __pyx_n_s__bvs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_10 = (__pyx_t_9 > 0);
        __pyx_t_11 = __pyx_t_10;
      } else {
        __pyx_t_11 = __pyx_t_8;
      }
      __pyx_t_8 = __pyx_t_11;
    } else {
      __pyx_t_8 = __pyx_t_7;
    }
    if (__pyx_t_8) {
 1563:                 bond_variables = group.bvs[current_no]
      /* "water_algorithm_cython.pyx":1563
 *         for wo in group.wos:
 *             if current_no != -1 and group.bvs != None and len(group.bvs) > 0:
 *                 bond_variables = group.bvs[current_no]             # <<<<<<<<<<<<<<
 *             else:
 *                 s = time()
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_group, __pyx_n_s__bvs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_v_current_no); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
      if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
      __pyx_v_bond_variables = __pyx_t_4;
      __pyx_t_4.memview = NULL;
      __pyx_t_4.data = NULL;
      goto __pyx_L5;
    }
    /*else*/ {
 1564:             else:
 1565:                 s = time()
      /* "water_algorithm_cython.pyx":1565
 *                 bond_variables = group.bvs[current_no]
 *             else:
 *                 s = time()             # <<<<<<<<<<<<<<
 *                 get_bond_variables_3(wo,  self.nearest_neighbors_nos, self.N, bond_variables)
 *                 self.conversion_time += time() - s
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_v_s);
      __pyx_v_s = __pyx_t_1;
      __pyx_t_1 = 0;
 1566:                 get_bond_variables_3(wo,  self.nearest_neighbors_nos, self.N, bond_variables)
      /* "water_algorithm_cython.pyx":1566
 *             else:
 *                 s = time()
 *                 get_bond_variables_3(wo,  self.nearest_neighbors_nos, self.N, bond_variables)             # <<<<<<<<<<<<<<
 *                 self.conversion_time += time() - s
 * 
 */
      __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_wo);
      if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_1);
      if (unlikely(!__pyx_t_13.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_12, __pyx_t_13, __pyx_v_self->N, __pyx_v_bond_variables);
      __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
 1567:                 self.conversion_time += time() - s
      /* "water_algorithm_cython.pyx":1567
 *                 s = time()
 *                 get_bond_variables_3(wo,  self.nearest_neighbors_nos, self.N, bond_variables)
 *                 self.conversion_time += time() - s             # <<<<<<<<<<<<<<
 * 
 *             res_group = group.try_subgroups(bond_variables.base, -1)
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_14 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_14, __pyx_v_s); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__conversion_time, __pyx_t_14) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __pyx_L5:;
 1568: 
 1569:             res_group = group.try_subgroups(bond_variables.base, -1)
    /* "water_algorithm_cython.pyx":1569
 *                 self.conversion_time += time() - s
 * 
 *             res_group = group.try_subgroups(bond_variables.base, -1)             # <<<<<<<<<<<<<<
 *             res_group.add_result(wo, None)
 *             print_("Result group length %i" % len(res_group.wos), self.logfile)
 */
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_group, __pyx_n_s__try_subgroups); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_bond_variables, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_int_neg_1);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_v_res_group);
    __pyx_v_res_group = __pyx_t_1;
    __pyx_t_1 = 0;
 1570:             res_group.add_result(wo, None)
    /* "water_algorithm_cython.pyx":1570
 * 
 *             res_group = group.try_subgroups(bond_variables.base, -1)
 *             res_group.add_result(wo, None)             # <<<<<<<<<<<<<<
 *             print_("Result group length %i" % len(res_group.wos), self.logfile)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_res_group, __pyx_n_s__add_result); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_wo);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_wo);
    __Pyx_GIVEREF(__pyx_v_wo);
    __Pyx_INCREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_3, 1, Py_None);
    __Pyx_GIVEREF(Py_None);
    __pyx_t_14 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
 1571:             print_("Result group length %i" % len(res_group.wos), self.logfile)
    /* "water_algorithm_cython.pyx":1571
 *             res_group = group.try_subgroups(bond_variables.base, -1)
 *             res_group.add_result(wo, None)
 *             print_("Result group length %i" % len(res_group.wos), self.logfile)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s__print_); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_res_group, __pyx_n_s__wos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_98), __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(__pyx_v_self->logfile);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->logfile);
    __Pyx_GIVEREF(__pyx_v_self->logfile);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.finalize_grouping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
  __Pyx_XDECREF(__pyx_v_wo);
  __Pyx_XDECREF(__pyx_v_s);
  __Pyx_XDECREF(__pyx_v_res_group);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1572: 
 1573: 
 1574: 
 1575:     @cython.boundscheck(False)
 1576:     cpdef np.ndarray[np.float_t, ndim=2] get_single_molecule_hydrogen_coordinates(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions,  DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] periodicity_axis, np.float_t[:, ::1] cell):
/* "water_algorithm_cython.pyx":1576
 * 
 *     @cython.boundscheck(False)
 *     cpdef np.ndarray[np.float_t, ndim=2] get_single_molecule_hydrogen_coordinates(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions,  DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] periodicity_axis, np.float_t[:, ::1] cell):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef np.float_t[:, ::1] result
 */

static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_55get_single_molecule_hydrogen_coordinates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_get_single_molecule_hydrogen_coordinates(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, CYTHON_UNUSED unsigned int __pyx_v_site, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation, unsigned int __pyx_v_i, __Pyx_memviewslice __pyx_v_oxygen_positions, __Pyx_memviewslice __pyx_v_nearest_neighbors_nos, __Pyx_memviewslice __pyx_v_nn_periodicity, __Pyx_memviewslice __pyx_v_periodicity_axis, __Pyx_memviewslice __pyx_v_cell, int __pyx_skip_dispatch) {
  __Pyx_memviewslice __pyx_v_bvv = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_result = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_real_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_oxygen_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_neighbor_oxygen_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_com = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_vector = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_5numpy_float_t __pyx_v_vector_length;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_x;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_index;
  __pyx_t_5numpy_float_t __pyx_v_distance;
  __pyx_t_5numpy_float_t __pyx_v_O_H_distance;
  unsigned int __pyx_v_n;
  unsigned int __pyx_v_counter;
  unsigned int __pyx_v_N;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_single_molecule_hydrogen_coordinates", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_99); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_55get_single_molecule_hydrogen_coordinates)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_site); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_to_py_npy_int8(__pyx_v_water_orientation); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (unlikely(!__pyx_v_oxygen_positions.memview)) { __Pyx_RaiseUnboundLocalError("oxygen_positions"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_oxygen_positions, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(!__pyx_v_nearest_neighbors_nos.memview)) { __Pyx_RaiseUnboundLocalError("nearest_neighbors_nos"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_nearest_neighbors_nos, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE_t, 0);; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      if (unlikely(!__pyx_v_nn_periodicity.memview)) { __Pyx_RaiseUnboundLocalError("nn_periodicity"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_nn_periodicity, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE_t, 0);; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(!__pyx_v_periodicity_axis.memview)) { __Pyx_RaiseUnboundLocalError("periodicity_axis"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_periodicity_axis, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE_t, 0);; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (unlikely(!__pyx_v_cell.memview)) { __Pyx_RaiseUnboundLocalError("cell"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_v_cell, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = PyTuple_New(8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_10, 7, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_9);
      __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

/* "water_algorithm_cython.pyx":1576
 * 
 *     @cython.boundscheck(False)
 *     cpdef np.ndarray[np.float_t, ndim=2] get_single_molecule_hydrogen_coordinates(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions,  DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] periodicity_axis, np.float_t[:, ::1] cell):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         cdef np.float_t[:, ::1] result
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_54get_single_molecule_hydrogen_coordinates(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, unsigned int __pyx_v_site, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation, unsigned int __pyx_v_i, __Pyx_memviewslice __pyx_v_oxygen_positions, __Pyx_memviewslice __pyx_v_nearest_neighbors_nos, __Pyx_memviewslice __pyx_v_nn_periodicity, __Pyx_memviewslice __pyx_v_periodicity_axis, __Pyx_memviewslice __pyx_v_cell) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_single_molecule_hydrogen_coordinates", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_oxygen_positions.memview)) { __Pyx_RaiseUnboundLocalError("oxygen_positions"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(!__pyx_v_nearest_neighbors_nos.memview)) { __Pyx_RaiseUnboundLocalError("nearest_neighbors_nos"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(!__pyx_v_nn_periodicity.memview)) { __Pyx_RaiseUnboundLocalError("nn_periodicity"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(!__pyx_v_periodicity_axis.memview)) { __Pyx_RaiseUnboundLocalError("periodicity_axis"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (unlikely(!__pyx_v_cell.memview)) { __Pyx_RaiseUnboundLocalError("cell"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_single_molecule_hydrogen_coordinates(__pyx_v_self, __pyx_v_site, __pyx_v_water_orientation, __pyx_v_i, __pyx_v_oxygen_positions, __pyx_v_nearest_neighbors_nos, __pyx_v_nn_periodicity, __pyx_v_periodicity_axis, __pyx_v_cell, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_single_molecule_hydrogen_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_oxygen_positions, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_nearest_neighbors_nos, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_nn_periodicity, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_periodicity_axis, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_cell, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1577:         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)
  /* "water_algorithm_cython.pyx":1577
 *     @cython.boundscheck(False)
 *     cpdef np.ndarray[np.float_t, ndim=2] get_single_molecule_hydrogen_coordinates(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions,  DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] periodicity_axis, np.float_t[:, ::1] cell):
 *         cdef DTYPE2_t[::1] bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         cdef np.float_t[:, ::1] result
 * 
 */
  __pyx_t_11 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_water_orientation); if (unlikely(!__pyx_t_11.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_bvv = __pyx_t_11;
  __pyx_t_11.memview = NULL;
  __pyx_t_11.data = NULL;
 1578:         cdef np.float_t[:, ::1] result
 1579: 
 1580:         cdef np.float_t[::1] add, real_position, oxygen_position = oxygen_positions.base[i], neighbor_oxygen_position, com
  /* "water_algorithm_cython.pyx":1580
 *         cdef np.float_t[:, ::1] result
 * 
 *         cdef np.float_t[::1] add, real_position, oxygen_position = oxygen_positions.base[i], neighbor_oxygen_position, com             # <<<<<<<<<<<<<<
 *         cdef np.float_t[::1] vector
 *         cdef np.float_t vector_length
 */
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_oxygen_positions, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_9, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_1);
  if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_oxygen_position = __pyx_t_12;
  __pyx_t_12.memview = NULL;
  __pyx_t_12.data = NULL;
 1581:         cdef np.float_t[::1] vector
 1582:         cdef np.float_t vector_length
 1583:         cdef DTYPE_t x, index = 0
  /* "water_algorithm_cython.pyx":1583
 *         cdef np.float_t[::1] vector
 *         cdef np.float_t vector_length
 *         cdef DTYPE_t x, index = 0             # <<<<<<<<<<<<<<
 *         cdef np.float_t distance, O_H_distance = self.O_H_distance
 *         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]
 */
  __pyx_v_index = 0;
 1584:         cdef np.float_t distance, O_H_distance = self.O_H_distance
  /* "water_algorithm_cython.pyx":1584
 *         cdef np.float_t vector_length
 *         cdef DTYPE_t x, index = 0
 *         cdef np.float_t distance, O_H_distance = self.O_H_distance             # <<<<<<<<<<<<<<
 *         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]
 *         if water_orientation < 6:
 */
  __pyx_t_13 = __pyx_v_self->O_H_distance;
  __pyx_v_O_H_distance = __pyx_t_13;
 1585:         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]
  /* "water_algorithm_cython.pyx":1585
 *         cdef DTYPE_t x, index = 0
 *         cdef np.float_t distance, O_H_distance = self.O_H_distance
 *         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]             # <<<<<<<<<<<<<<
 *         if water_orientation < 6:
 *             result = np.zeros((2, 3), dtype=DTYPE4)
 */
  __pyx_v_counter = 0;
  __pyx_v_N = (__pyx_v_nearest_neighbors_nos.shape[0]);
 1586:         if water_orientation < 6:
  /* "water_algorithm_cython.pyx":1586
 *         cdef np.float_t distance, O_H_distance = self.O_H_distance
 *         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]
 *         if water_orientation < 6:             # <<<<<<<<<<<<<<
 *             result = np.zeros((2, 3), dtype=DTYPE4)
 *         elif water_orientation > 9:
 */
  __pyx_t_14 = (__pyx_v_water_orientation < 6);
  if (__pyx_t_14) {
 1587:             result = np.zeros((2, 3), dtype=DTYPE4)
    /* "water_algorithm_cython.pyx":1587
 *         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]
 *         if water_orientation < 6:
 *             result = np.zeros((2, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         elif water_orientation > 9:
 *             result = np.zeros((3, 3), dtype=DTYPE4)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "water_algorithm_cython.pyx":1587
 *         cdef unsigned int n, counter = 0, N = nearest_neighbors_nos.shape[0]
 *         if water_orientation < 6:
 *             result = np.zeros((2, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         elif water_orientation > 9:
 *             result = np.zeros((3, 3), dtype=DTYPE4)
 */
  __pyx_k_tuple_100 = PyTuple_Pack(2, __pyx_int_2, __pyx_int_3); if (unlikely(!__pyx_k_tuple_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_100);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_100));
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_k_tuple_101), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_t_10);
    if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_v_result = __pyx_t_15;
    __pyx_t_15.memview = NULL;
    __pyx_t_15.data = NULL;
    goto __pyx_L3;
  }
  __pyx_k_tuple_101 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_100)); if (unlikely(!__pyx_k_tuple_101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_101);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_101));
 1588:         elif water_orientation > 9:
  /* "water_algorithm_cython.pyx":1588
 *         if water_orientation < 6:
 *             result = np.zeros((2, 3), dtype=DTYPE4)
 *         elif water_orientation > 9:             # <<<<<<<<<<<<<<
 *             result = np.zeros((3, 3), dtype=DTYPE4)
 *         else:
 */
  __pyx_t_14 = (__pyx_v_water_orientation > 9);
  if (__pyx_t_14) {
 1589:             result = np.zeros((3, 3), dtype=DTYPE4)
    /* "water_algorithm_cython.pyx":1589
 *             result = np.zeros((2, 3), dtype=DTYPE4)
 *         elif water_orientation > 9:
 *             result = np.zeros((3, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         else:
 *             result = np.zeros((1, 3), dtype=DTYPE4)
 */
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "water_algorithm_cython.pyx":1589
 *             result = np.zeros((2, 3), dtype=DTYPE4)
 *         elif water_orientation > 9:
 *             result = np.zeros((3, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         else:
 *             result = np.zeros((1, 3), dtype=DTYPE4)
 */
  __pyx_k_tuple_102 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_3); if (unlikely(!__pyx_k_tuple_102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_102);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_102));
    __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_10));
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__dtype), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_103), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
    __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_t_9);
    if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_result = __pyx_t_15;
    __pyx_t_15.memview = NULL;
    __pyx_t_15.data = NULL;
    goto __pyx_L3;
  }
  /*else*/ {
  __pyx_k_tuple_103 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_102)); if (unlikely(!__pyx_k_tuple_103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_103);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_103));
 1590:         else:
 1591:             result = np.zeros((1, 3), dtype=DTYPE4)
    /* "water_algorithm_cython.pyx":1591
 *             result = np.zeros((3, 3), dtype=DTYPE4)
 *         else:
 *             result = np.zeros((1, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         for n from 0 <= n < N:
 *             x  = nearest_neighbors_nos[n]
 */
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__zeros); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "water_algorithm_cython.pyx":1591
 *             result = np.zeros((3, 3), dtype=DTYPE4)
 *         else:
 *             result = np.zeros((1, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         for n from 0 <= n < N:
 *             x  = nearest_neighbors_nos[n]
 */
  __pyx_k_tuple_104 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_3); if (unlikely(!__pyx_k_tuple_104)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_104);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_104));
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_105), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
    __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_t_1);
    if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_result = __pyx_t_15;
    __pyx_t_15.memview = NULL;
    __pyx_t_15.data = NULL;
  }
  __pyx_L3:;
  __pyx_k_tuple_105 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_104)); if (unlikely(!__pyx_k_tuple_105)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_105);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_105));
 1592:         for n from 0 <= n < N:
  /* "water_algorithm_cython.pyx":1592
 *         else:
 *             result = np.zeros((1, 3), dtype=DTYPE4)
 *         for n from 0 <= n < N:             # <<<<<<<<<<<<<<
 *             x  = nearest_neighbors_nos[n]
 *             if bvv[n] == 1:
 */
  __pyx_t_16 = __pyx_v_N;
  for (__pyx_v_n = 0; __pyx_v_n < __pyx_t_16; __pyx_v_n++) {
 1593:             x  = nearest_neighbors_nos[n]
    /* "water_algorithm_cython.pyx":1593
 *             result = np.zeros((1, 3), dtype=DTYPE4)
 *         for n from 0 <= n < N:
 *             x  = nearest_neighbors_nos[n]             # <<<<<<<<<<<<<<
 *             if bvv[n] == 1:
 *                 if i != x or nn_periodicity[n]:
 */
    __pyx_t_17 = __pyx_v_n;
    __pyx_v_x = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nearest_neighbors_nos.data) + __pyx_t_17)) )));
 1594:             if bvv[n] == 1:
    /* "water_algorithm_cython.pyx":1594
 *         for n from 0 <= n < N:
 *             x  = nearest_neighbors_nos[n]
 *             if bvv[n] == 1:             # <<<<<<<<<<<<<<
 *                 if i != x or nn_periodicity[n]:
 *                     neighbor_oxygen_position = oxygen_positions[x]
 */
    __pyx_t_18 = __pyx_v_n;
    __pyx_t_14 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_18)) ))) == 1);
    if (__pyx_t_14) {
 1595:                 if i != x or nn_periodicity[n]:
      /* "water_algorithm_cython.pyx":1595
 *             x  = nearest_neighbors_nos[n]
 *             if bvv[n] == 1:
 *                 if i != x or nn_periodicity[n]:             # <<<<<<<<<<<<<<
 *                     neighbor_oxygen_position = oxygen_positions[x]
 *                     if nn_periodicity[n]:
 */
      __pyx_t_14 = (__pyx_v_i != __pyx_v_x);
      if (!__pyx_t_14) {
        __pyx_t_19 = __pyx_v_n;
        __pyx_t_20 = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nn_periodicity.data) + __pyx_t_19)) )));
      } else {
        __pyx_t_20 = __pyx_t_14;
      }
      if (__pyx_t_20) {
 1596:                     neighbor_oxygen_position = oxygen_positions[x]
        /* "water_algorithm_cython.pyx":1596
 *             if bvv[n] == 1:
 *                 if i != x or nn_periodicity[n]:
 *                     neighbor_oxygen_position = oxygen_positions[x]             # <<<<<<<<<<<<<<
 *                     if nn_periodicity[n]:
 *                         distance,  real_position = get_periodic_distance(oxygen_position, neighbor_oxygen_position, cell, periodicity_axis[n])
 */
        __pyx_t_22 = -1;
        __pyx_t_21.data = __pyx_v_oxygen_positions.data;
        __pyx_t_21.memview = __pyx_v_oxygen_positions.memview;
        __PYX_INC_MEMVIEW(&__pyx_t_21, 0);
        {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_x;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_oxygen_positions.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_oxygen_positions.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_21.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_21.shape[0] = __pyx_v_oxygen_positions.shape[1];
__pyx_t_21.strides[0] = __pyx_v_oxygen_positions.strides[1];
    __pyx_t_21.suboffsets[0] = -1;

__PYX_XDEC_MEMVIEW(&__pyx_v_neighbor_oxygen_position, 1);
        __pyx_v_neighbor_oxygen_position = __pyx_t_21;
        __pyx_t_21.memview = NULL;
        __pyx_t_21.data = NULL;
 1597:                     if nn_periodicity[n]:
        /* "water_algorithm_cython.pyx":1597
 *                 if i != x or nn_periodicity[n]:
 *                     neighbor_oxygen_position = oxygen_positions[x]
 *                     if nn_periodicity[n]:             # <<<<<<<<<<<<<<
 *                         distance,  real_position = get_periodic_distance(oxygen_position, neighbor_oxygen_position, cell, periodicity_axis[n])
 *                     else:
 */
        __pyx_t_23 = __pyx_v_n;
        __pyx_t_24 = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nn_periodicity.data) + __pyx_t_23)) )));
        if (__pyx_t_24) {
 1598:                         distance,  real_position = get_periodic_distance(oxygen_position, neighbor_oxygen_position, cell, periodicity_axis[n])
          /* "water_algorithm_cython.pyx":1598
 *                     neighbor_oxygen_position = oxygen_positions[x]
 *                     if nn_periodicity[n]:
 *                         distance,  real_position = get_periodic_distance(oxygen_position, neighbor_oxygen_position, cell, periodicity_axis[n])             # <<<<<<<<<<<<<<
 *                     else:
 *                         distance = euler_norm(reduce(oxygen_position, neighbor_oxygen_position))
 */
          __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_106); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_v_oxygen_position, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = __pyx_memoryview_fromslice(__pyx_v_neighbor_oxygen_position, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_cell, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_25 = __pyx_v_n;
          __pyx_t_7 = __Pyx_PyInt_to_py_npy_uint8((*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_periodicity_axis.data) + __pyx_t_25)) )))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_9 = 0;
          __pyx_t_10 = 0;
          __pyx_t_8 = 0;
          __pyx_t_7 = 0;
          __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
          if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
            PyObject* sequence = __pyx_t_7;
            #if CYTHON_COMPILING_IN_CPYTHON
            Py_ssize_t size = Py_SIZE(sequence);
            #else
            Py_ssize_t size = PySequence_Size(sequence);
            #endif
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            #if CYTHON_COMPILING_IN_CPYTHON
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            #else
            __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            #endif
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          } else
          {
            Py_ssize_t index = -1;
            __pyx_t_8 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_26 = Py_TYPE(__pyx_t_8)->tp_iternext;
            index = 0; __pyx_t_6 = __pyx_t_26(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L9_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_6);
            index = 1; __pyx_t_1 = __pyx_t_26(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_1);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_26(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_26 = NULL;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            goto __pyx_L10_unpacking_done;
            __pyx_L9_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __pyx_t_26 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_L10_unpacking_done:;
          }
          __pyx_t_27 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_27 == (npy_double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_1);
          if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_v_distance = __pyx_t_27;
          __PYX_XDEC_MEMVIEW(&__pyx_v_real_position, 1);
          __pyx_v_real_position = __pyx_t_12;
          __pyx_t_12.memview = NULL;
          __pyx_t_12.data = NULL;
          goto __pyx_L8;
        }
        /*else*/ {
 1599:                     else:
 1600:                         distance = euler_norm(reduce(oxygen_position, neighbor_oxygen_position))
          /* "water_algorithm_cython.pyx":1600
 *                         distance,  real_position = get_periodic_distance(oxygen_position, neighbor_oxygen_position, cell, periodicity_axis[n])
 *                     else:
 *                         distance = euler_norm(reduce(oxygen_position, neighbor_oxygen_position))             # <<<<<<<<<<<<<<
 *                         real_position = neighbor_oxygen_position
 *                     result[index] = reduce(oxygen_position, divide(multiply(O_H_distance, reduce(oxygen_position, real_position)), distance))
 */
          __pyx_t_28 = __pyx_f_22water_algorithm_cython_reduce(__pyx_v_oxygen_position, __pyx_v_neighbor_oxygen_position); if (unlikely(!__pyx_t_28.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_v_distance = __pyx_f_22water_algorithm_cython_euler_norm(__pyx_t_28);
          __PYX_XDEC_MEMVIEW(&__pyx_t_28, 1);
 1601:                         real_position = neighbor_oxygen_position
          /* "water_algorithm_cython.pyx":1601
 *                     else:
 *                         distance = euler_norm(reduce(oxygen_position, neighbor_oxygen_position))
 *                         real_position = neighbor_oxygen_position             # <<<<<<<<<<<<<<
 *                     result[index] = reduce(oxygen_position, divide(multiply(O_H_distance, reduce(oxygen_position, real_position)), distance))
 *                     index += 1
 */
          __PYX_XDEC_MEMVIEW(&__pyx_v_real_position, 1);
          __PYX_INC_MEMVIEW(&__pyx_v_neighbor_oxygen_position, 0);
          __pyx_v_real_position = __pyx_v_neighbor_oxygen_position;
        }
        __pyx_L8:;
 1602:                     result[index] = reduce(oxygen_position, divide(multiply(O_H_distance, reduce(oxygen_position, real_position)), distance))
        /* "water_algorithm_cython.pyx":1602
 *                         distance = euler_norm(reduce(oxygen_position, neighbor_oxygen_position))
 *                         real_position = neighbor_oxygen_position
 *                     result[index] = reduce(oxygen_position, divide(multiply(O_H_distance, reduce(oxygen_position, real_position)), distance))             # <<<<<<<<<<<<<<
 *                     index += 1
 *                 else:
 */
        __pyx_t_28 = __pyx_f_22water_algorithm_cython_reduce(__pyx_v_oxygen_position, __pyx_v_real_position); if (unlikely(!__pyx_t_28.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_29 = __pyx_f_22water_algorithm_cython_multiply(__pyx_v_O_H_distance, __pyx_t_28); if (unlikely(!__pyx_t_29.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_28, 1);
        __pyx_t_30 = __pyx_f_22water_algorithm_cython_divide(__pyx_t_29, __pyx_v_distance); if (unlikely(!__pyx_t_30.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_29, 1);
        __pyx_t_28 = __pyx_f_22water_algorithm_cython_reduce(__pyx_v_oxygen_position, __pyx_t_30); if (unlikely(!__pyx_t_28.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_30, 1);
        __pyx_t_22 = -1;
        __pyx_t_31.data = __pyx_v_result.data;
        __pyx_t_31.memview = __pyx_v_result.memview;
        __PYX_INC_MEMVIEW(&__pyx_t_31, 0);
        {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_index;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_result.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_result.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_31.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_31.shape[0] = __pyx_v_result.shape[1];
__pyx_t_31.strides[0] = __pyx_v_result.strides[1];
    __pyx_t_31.suboffsets[0] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_t_28, __pyx_t_31, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
        __PYX_XDEC_MEMVIEW(&__pyx_t_28, 1);
 1603:                     index += 1
        /* "water_algorithm_cython.pyx":1603
 *                         real_position = neighbor_oxygen_position
 *                     result[index] = reduce(oxygen_position, divide(multiply(O_H_distance, reduce(oxygen_position, real_position)), distance))
 *                     index += 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     counter += 1
 */
        __pyx_v_index = (__pyx_v_index + 1);
        goto __pyx_L7;
      }
      /*else*/ {
 1604:                 else:
 1605:                     counter += 1
        /* "water_algorithm_cython.pyx":1605
 *                     index += 1
 *                 else:
 *                     counter += 1             # <<<<<<<<<<<<<<
 *                     if counter == 2:
 *                         vector = np.array([0, 0, -1], dtype=float)
 */
        __pyx_v_counter = (__pyx_v_counter + 1);
 1606:                     if counter == 2:
        /* "water_algorithm_cython.pyx":1606
 *                 else:
 *                     counter += 1
 *                     if counter == 2:             # <<<<<<<<<<<<<<
 *                         vector = np.array([0, 0, -1], dtype=float)
 *                     else:
 */
        __pyx_t_20 = (__pyx_v_counter == 2);
        if (__pyx_t_20) {
 1607:                         vector = np.array([0, 0, -1], dtype=float)
          /* "water_algorithm_cython.pyx":1607
 *                     counter += 1
 *                     if counter == 2:
 *                         vector = np.array([0, 0, -1], dtype=float)             # <<<<<<<<<<<<<<
 *                     else:
 *                         com = get_nn_com(i, nearest_neighbors_nos, oxygen_positions, periodicity_axis,  cell)
 */
          __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_INCREF(__pyx_int_0);
          PyList_SET_ITEM(__pyx_t_7, 0, __pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          __Pyx_INCREF(__pyx_int_0);
          PyList_SET_ITEM(__pyx_t_7, 1, __pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          __Pyx_INCREF(__pyx_int_neg_1);
          PyList_SET_ITEM(__pyx_t_7, 2, __pyx_int_neg_1);
          __Pyx_GIVEREF(__pyx_int_neg_1);
          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_7));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
          __pyx_t_7 = 0;
          __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
          if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)((PyObject*)(&PyFloat_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
          __pyx_t_32 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_8);
          if (unlikely(!__pyx_t_32.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __PYX_XDEC_MEMVIEW(&__pyx_v_vector, 1);
          __pyx_v_vector = __pyx_t_32;
          __pyx_t_32.memview = NULL;
          __pyx_t_32.data = NULL;
          goto __pyx_L11;
        }
        /*else*/ {
 1608:                     else:
 1609:                         com = get_nn_com(i, nearest_neighbors_nos, oxygen_positions, periodicity_axis,  cell)
          /* "water_algorithm_cython.pyx":1609
 *                         vector = np.array([0, 0, -1], dtype=float)
 *                     else:
 *                         com = get_nn_com(i, nearest_neighbors_nos, oxygen_positions, periodicity_axis,  cell)             # <<<<<<<<<<<<<<
 *                         vector = reduce(oxygen_position, com)
 *                         # normalize the vector
 */
          __pyx_t_8 = ((PyObject *)__pyx_f_22water_algorithm_cython_get_nn_com(__pyx_v_i, __pyx_v_nearest_neighbors_nos, __pyx_v_oxygen_positions, __pyx_v_periodicity_axis, __pyx_v_cell)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_8);
          if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __PYX_XDEC_MEMVIEW(&__pyx_v_com, 1);
          __pyx_v_com = __pyx_t_12;
          __pyx_t_12.memview = NULL;
          __pyx_t_12.data = NULL;
 1610:                         vector = reduce(oxygen_position, com)
          /* "water_algorithm_cython.pyx":1610
 *                     else:
 *                         com = get_nn_com(i, nearest_neighbors_nos, oxygen_positions, periodicity_axis,  cell)
 *                         vector = reduce(oxygen_position, com)             # <<<<<<<<<<<<<<
 *                         # normalize the vector
 *                         vector_length = euler_norm(vector)
 */
          __pyx_t_28 = __pyx_f_22water_algorithm_cython_reduce(__pyx_v_oxygen_position, __pyx_v_com); if (unlikely(!__pyx_t_28.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __PYX_XDEC_MEMVIEW(&__pyx_v_vector, 1);
          __pyx_v_vector = __pyx_t_28;
          __pyx_t_28.memview = NULL;
          __pyx_t_28.data = NULL;
 1611:                         # normalize the vector
 1612:                         vector_length = euler_norm(vector)
          /* "water_algorithm_cython.pyx":1612
 *                         vector = reduce(oxygen_position, com)
 *                         # normalize the vector
 *                         vector_length = euler_norm(vector)             # <<<<<<<<<<<<<<
 *                         vector = divide(vector, vector_length)
 *                     # the dangling hydrogen is along this vector
 */
          __pyx_v_vector_length = __pyx_f_22water_algorithm_cython_euler_norm(__pyx_v_vector);
 1613:                         vector = divide(vector, vector_length)
          /* "water_algorithm_cython.pyx":1613
 *                         # normalize the vector
 *                         vector_length = euler_norm(vector)
 *                         vector = divide(vector, vector_length)             # <<<<<<<<<<<<<<
 *                     # the dangling hydrogen is along this vector
 *                     result[index] = add_together(oxygen_position, multiply(O_H_distance, vector))
 */
          __pyx_t_30 = __pyx_f_22water_algorithm_cython_divide(__pyx_v_vector, __pyx_v_vector_length); if (unlikely(!__pyx_t_30.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __PYX_XDEC_MEMVIEW(&__pyx_v_vector, 1);
          __pyx_v_vector = __pyx_t_30;
          __pyx_t_30.memview = NULL;
          __pyx_t_30.data = NULL;
        }
        __pyx_L11:;
 1614:                     # the dangling hydrogen is along this vector
 1615:                     result[index] = add_together(oxygen_position, multiply(O_H_distance, vector))
        /* "water_algorithm_cython.pyx":1615
 *                         vector = divide(vector, vector_length)
 *                     # the dangling hydrogen is along this vector
 *                     result[index] = add_together(oxygen_position, multiply(O_H_distance, vector))             # <<<<<<<<<<<<<<
 *                     index += 1
 *         return result.base
 */
        __pyx_t_29 = __pyx_f_22water_algorithm_cython_multiply(__pyx_v_O_H_distance, __pyx_v_vector); if (unlikely(!__pyx_t_29.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_33 = __pyx_f_22water_algorithm_cython_add_together(__pyx_v_oxygen_position, __pyx_t_29); if (unlikely(!__pyx_t_33.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_29, 1);
        __pyx_t_22 = -1;
        __pyx_t_34.data = __pyx_v_result.data;
        __pyx_t_34.memview = __pyx_v_result.memview;
        __PYX_INC_MEMVIEW(&__pyx_t_34, 0);
        {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_index;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_result.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_result.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_34.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_34.shape[0] = __pyx_v_result.shape[1];
__pyx_t_34.strides[0] = __pyx_v_result.strides[1];
    __pyx_t_34.suboffsets[0] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_t_33, __pyx_t_34, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __PYX_XDEC_MEMVIEW(&__pyx_t_34, 1);
        __PYX_XDEC_MEMVIEW(&__pyx_t_33, 1);
 1616:                     index += 1
        /* "water_algorithm_cython.pyx":1616
 *                     # the dangling hydrogen is along this vector
 *                     result[index] = add_together(oxygen_position, multiply(O_H_distance, vector))
 *                     index += 1             # <<<<<<<<<<<<<<
 *         return result.base
 * 
 */
        __pyx_v_index = (__pyx_v_index + 1);
      }
      __pyx_L7:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
 1617:         return result.base
  /* "water_algorithm_cython.pyx":1617
 *                     result[index] = add_together(oxygen_position, multiply(O_H_distance, vector))
 *                     index += 1
 *         return result.base             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_result, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s__base); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_28, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_29, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_30, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_32, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_33, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_34, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_single_molecule_hydrogen_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_result, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_real_position, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_oxygen_position, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_neighbor_oxygen_position, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_com, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_vector, 1);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_55get_single_molecule_hydrogen_coordinates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_55get_single_molecule_hydrogen_coordinates(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  unsigned int __pyx_v_site;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation;
  unsigned int __pyx_v_i;
  __Pyx_memviewslice __pyx_v_oxygen_positions = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_nearest_neighbors_nos = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_nn_periodicity = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_periodicity_axis = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_cell = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_single_molecule_hydrogen_coordinates (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__site,&__pyx_n_s__water_orientation,&__pyx_n_s__i,&__pyx_n_s__oxygen_positions,&__pyx_n_s_14,&__pyx_n_s__nn_periodicity,&__pyx_n_s__periodicity_axis,&__pyx_n_s__cell,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__site)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__oxygen_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_14)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nn_periodicity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodicity_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  7:
        if (likely((values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_single_molecule_hydrogen_coordinates") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
    }
    __pyx_v_site = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_site == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_water_orientation = __Pyx_PyInt_from_py_npy_int8(values[1]); if (unlikely((__pyx_v_water_orientation == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_i = __Pyx_PyInt_AsUnsignedInt(values[2]); if (unlikely((__pyx_v_i == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_oxygen_positions = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(values[3]); if (unlikely(!__pyx_v_oxygen_positions.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_nearest_neighbors_nos = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(values[4]); if (unlikely(!__pyx_v_nearest_neighbors_nos.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_nn_periodicity = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(values[5]); if (unlikely(!__pyx_v_nn_periodicity.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_periodicity_axis = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(values[6]); if (unlikely(!__pyx_v_periodicity_axis.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_cell = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(values[7]); if (unlikely(!__pyx_v_cell.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_single_molecule_hydrogen_coordinates", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_single_molecule_hydrogen_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_54get_single_molecule_hydrogen_coordinates(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_site, __pyx_v_water_orientation, __pyx_v_i, __pyx_v_oxygen_positions, __pyx_v_nearest_neighbors_nos, __pyx_v_nn_periodicity, __pyx_v_periodicity_axis, __pyx_v_cell);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1618: 
 1619:     @cython.boundscheck(False)
 1620:     cdef np.float_t[::1] get_single_molecule_dipole_moment(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] nn_periodicity_axis):
/* "water_algorithm_cython.pyx":1620
 * 
 *     @cython.boundscheck(False)
 *     cdef np.float_t[::1] get_single_molecule_dipole_moment(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] nn_periodicity_axis):             # <<<<<<<<<<<<<<
 *         cdef np.float_t[:, ::1] h_coordinates = self.get_single_molecule_hydrogen_coordinates(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos, nn_periodicity, nn_periodicity_axis, self.cell)
 *         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]
 */

static __Pyx_memviewslice __pyx_f_22water_algorithm_cython_14WaterAlgorithm_get_single_molecule_dipole_moment(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, unsigned int __pyx_v_site, __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation, unsigned int __pyx_v_i, __Pyx_memviewslice __pyx_v_oxygen_positions, __Pyx_memviewslice __pyx_v_nearest_neighbors_nos, __Pyx_memviewslice __pyx_v_nn_periodicity, __Pyx_memviewslice __pyx_v_nn_periodicity_axis) {
  __Pyx_memviewslice __pyx_v_h_coordinates = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_oxygen_position = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dipole_moment = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_5numpy_float_t __pyx_v_O_H_distance;
  unsigned int __pyx_v_j;
  unsigned int __pyx_v_N;
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_single_molecule_dipole_moment", 0);
 1621:         cdef np.float_t[:, ::1] h_coordinates = self.get_single_molecule_hydrogen_coordinates(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos, nn_periodicity, nn_periodicity_axis, self.cell)
  /* "water_algorithm_cython.pyx":1621
 *     @cython.boundscheck(False)
 *     cdef np.float_t[::1] get_single_molecule_dipole_moment(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] nn_periodicity_axis):
 *         cdef np.float_t[:, ::1] h_coordinates = self.get_single_molecule_hydrogen_coordinates(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos, nn_periodicity, nn_periodicity_axis, self.cell)             # <<<<<<<<<<<<<<
 *         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]
 *         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)
 */
  __pyx_t_1 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_v_self->cell);
  if (unlikely(!__pyx_t_1.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_single_molecule_hydrogen_coordinates(__pyx_v_self, __pyx_v_site, __pyx_v_water_orientation, __pyx_v_i, __pyx_v_oxygen_positions, __pyx_v_nearest_neighbors_nos, __pyx_v_nn_periodicity, __pyx_v_nn_periodicity_axis, __pyx_t_1, 0)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
  __pyx_t_3 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_t_2);
  if (unlikely(!__pyx_t_3.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_h_coordinates = __pyx_t_3;
  __pyx_t_3.memview = NULL;
  __pyx_t_3.data = NULL;
 1622:         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]
  /* "water_algorithm_cython.pyx":1622
 *     cdef np.float_t[::1] get_single_molecule_dipole_moment(self, unsigned int site, DTYPE2_t water_orientation, unsigned int i, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nearest_neighbors_nos, DTYPE_t[::1] nn_periodicity, DTYPE_t[::1] nn_periodicity_axis):
 *         cdef np.float_t[:, ::1] h_coordinates = self.get_single_molecule_hydrogen_coordinates(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos, nn_periodicity, nn_periodicity_axis, self.cell)
 *         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]             # <<<<<<<<<<<<<<
 *         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)
 *         cdef np.float_t O_H_distance = self.O_H_distance
 */
  __pyx_t_5 = -1;
  __pyx_t_4.data = __pyx_v_oxygen_positions.data;
  __pyx_t_4.memview = __pyx_v_oxygen_positions.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_4, 0);
  {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_oxygen_positions.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_oxygen_positions.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_4.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_4.shape[0] = __pyx_v_oxygen_positions.shape[1];
__pyx_t_4.strides[0] = __pyx_v_oxygen_positions.strides[1];
    __pyx_t_4.suboffsets[0] = -1;

__pyx_v_oxygen_position = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 1623:         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)
  /* "water_algorithm_cython.pyx":1623
 *         cdef np.float_t[:, ::1] h_coordinates = self.get_single_molecule_hydrogen_coordinates(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos, nn_periodicity, nn_periodicity_axis, self.cell)
 *         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]
 *         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         cdef np.float_t O_H_distance = self.O_H_distance
 *         cdef unsigned int j, N = h_coordinates.shape[0]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_107), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_7);
  if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_dipole_moment = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;

  /* "water_algorithm_cython.pyx":1623
 *         cdef np.float_t[:, ::1] h_coordinates = self.get_single_molecule_hydrogen_coordinates(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos, nn_periodicity, nn_periodicity_axis, self.cell)
 *         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]
 *         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         cdef np.float_t O_H_distance = self.O_H_distance
 *         cdef unsigned int j, N = h_coordinates.shape[0]
 */
  __pyx_k_tuple_107 = PyTuple_Pack(1, __pyx_int_3); if (unlikely(!__pyx_k_tuple_107)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_107);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_107));
 1624:         cdef np.float_t O_H_distance = self.O_H_distance
  /* "water_algorithm_cython.pyx":1624
 *         cdef np.float_t[::1] h_coordinate,  oxygen_position = oxygen_positions[i]
 *         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)
 *         cdef np.float_t O_H_distance = self.O_H_distance             # <<<<<<<<<<<<<<
 *         cdef unsigned int j, N = h_coordinates.shape[0]
 * 
 */
  __pyx_t_9 = __pyx_v_self->O_H_distance;
  __pyx_v_O_H_distance = __pyx_t_9;
 1625:         cdef unsigned int j, N = h_coordinates.shape[0]
  /* "water_algorithm_cython.pyx":1625
 *         cdef np.float_t[::1] dipole_moment = np.zeros(3, dtype=DTYPE4)
 *         cdef np.float_t O_H_distance = self.O_H_distance
 *         cdef unsigned int j, N = h_coordinates.shape[0]             # <<<<<<<<<<<<<<
 * 
 *         for j from 0 <= j < N:
 */
  __pyx_v_N = (__pyx_v_h_coordinates.shape[0]);
 1626: 
 1627:         for j from 0 <= j < N:
  /* "water_algorithm_cython.pyx":1627
 *         cdef unsigned int j, N = h_coordinates.shape[0]
 * 
 *         for j from 0 <= j < N:             # <<<<<<<<<<<<<<
 *             add_to_dipole_moment_estimate(h_coordinates[j], oxygen_position, O_H_distance, dipole_moment)
 * 
 */
  __pyx_t_10 = __pyx_v_N;
  for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_10; __pyx_v_j++) {
 1628:             add_to_dipole_moment_estimate(h_coordinates[j], oxygen_position, O_H_distance, dipole_moment)
    /* "water_algorithm_cython.pyx":1628
 * 
 *         for j from 0 <= j < N:
 *             add_to_dipole_moment_estimate(h_coordinates[j], oxygen_position, O_H_distance, dipole_moment)             # <<<<<<<<<<<<<<
 * 
 *         return dipole_moment
 */
    __pyx_t_5 = -1;
    __pyx_t_11.data = __pyx_v_h_coordinates.data;
    __pyx_t_11.memview = __pyx_v_h_coordinates.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_11, 0);
    {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_j;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_h_coordinates.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_h_coordinates.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_11.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_11.shape[0] = __pyx_v_h_coordinates.shape[1];
__pyx_t_11.strides[0] = __pyx_v_h_coordinates.strides[1];
    __pyx_t_11.suboffsets[0] = -1;

__pyx_f_22water_algorithm_cython_add_to_dipole_moment_estimate(__pyx_t_11, __pyx_v_oxygen_position, __pyx_v_O_H_distance, __pyx_v_dipole_moment);
    __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  }
 1629: 
 1630:         return dipole_moment
  /* "water_algorithm_cython.pyx":1630
 *             add_to_dipole_moment_estimate(h_coordinates[j], oxygen_position, O_H_distance, dipole_moment)
 * 
 *         return dipole_moment             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __PYX_INC_MEMVIEW(&__pyx_v_dipole_moment, 0);
  __pyx_r = __pyx_v_dipole_moment;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
  __Pyx_XDECREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_single_molecule_dipole_moment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_r;
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError,"Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_h_coordinates, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_oxygen_position, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dipole_moment, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1631: 
 1632:     @cython.boundscheck(False)
 1633:     cpdef np.ndarray[np.float_t, ndim=1] get_total_dipole_moments(self, DTYPE2_t[:, ::1] wos):
/* "water_algorithm_cython.pyx":1633
 * 
 *     @cython.boundscheck(False)
 *     cpdef np.ndarray[np.float_t, ndim=1] get_total_dipole_moments(self, DTYPE2_t[:, ::1] wos):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] wo
 *         cdef unsigned int i, N = wos.shape[0]
 */

static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_57get_total_dipole_moments(PyObject *__pyx_v_self, PyObject *__pyx_arg_wos); /*proto*/
static PyArrayObject *__pyx_f_22water_algorithm_cython_14WaterAlgorithm_get_total_dipole_moments(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_wos, int __pyx_skip_dispatch) {
  __Pyx_memviewslice __pyx_v_wo = { 0, 0, { 0 }, { 0 }, { 0 } };
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_N;
  __Pyx_memviewslice __pyx_v_total_dipole_moments = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_total_dipole_moments", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_108); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_57get_total_dipole_moments)) {
      __Pyx_XDECREF(((PyObject *)__pyx_r));
      if (unlikely(!__pyx_v_wos.memview)) { __Pyx_RaiseUnboundLocalError("wos"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_wos, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_r = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

/* "water_algorithm_cython.pyx":1633
 * 
 *     @cython.boundscheck(False)
 *     cpdef np.ndarray[np.float_t, ndim=1] get_total_dipole_moments(self, DTYPE2_t[:, ::1] wos):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[::1] wo
 *         cdef unsigned int i, N = wos.shape[0]
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_56get_total_dipole_moments(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_wos) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_total_dipole_moments", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_wos.memview)) { __Pyx_RaiseUnboundLocalError("wos"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_total_dipole_moments(__pyx_v_self, __pyx_v_wos, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_total_dipole_moments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_wos, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1634:         cdef DTYPE2_t[::1] wo
 1635:         cdef unsigned int i, N = wos.shape[0]
  /* "water_algorithm_cython.pyx":1635
 *     cpdef np.ndarray[np.float_t, ndim=1] get_total_dipole_moments(self, DTYPE2_t[:, ::1] wos):
 *         cdef DTYPE2_t[::1] wo
 *         cdef unsigned int i, N = wos.shape[0]             # <<<<<<<<<<<<<<
 *         cdef np.float_t[:, ::1] total_dipole_moments = np.ndarray((N, 3), dtype=DTYPE4)
 *         for i from 0 <= i < N:
 */
  __pyx_v_N = (__pyx_v_wos.shape[0]);
 1636:         cdef np.float_t[:, ::1] total_dipole_moments = np.ndarray((N, 3), dtype=DTYPE4)
  /* "water_algorithm_cython.pyx":1636
 *         cdef DTYPE2_t[::1] wo
 *         cdef unsigned int i, N = wos.shape[0]
 *         cdef np.float_t[:, ::1] total_dipole_moments = np.ndarray((N, 3), dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < N:
 *             wo = wos[i]
 */
  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(__pyx_t_3);
  if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_total_dipole_moments = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 1637:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":1637
 *         cdef unsigned int i, N = wos.shape[0]
 *         cdef np.float_t[:, ::1] total_dipole_moments = np.ndarray((N, 3), dtype=DTYPE4)
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             wo = wos[i]
 *             total_dipole_moments[i] = self.get_total_dipole_moment(wo)
 */
  __pyx_t_5 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
 1638:             wo = wos[i]
    /* "water_algorithm_cython.pyx":1638
 *         cdef np.float_t[:, ::1] total_dipole_moments = np.ndarray((N, 3), dtype=DTYPE4)
 *         for i from 0 <= i < N:
 *             wo = wos[i]             # <<<<<<<<<<<<<<
 *             total_dipole_moments[i] = self.get_total_dipole_moment(wo)
 *             if i % 1000 == 0:
 */
    __pyx_t_7 = -1;
    __pyx_t_6.data = __pyx_v_wos.data;
    __pyx_t_6.memview = __pyx_v_wos.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
    {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_wos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_wos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_6.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_6.shape[0] = __pyx_v_wos.shape[1];
__pyx_t_6.strides[0] = __pyx_v_wos.strides[1];
    __pyx_t_6.suboffsets[0] = -1;

__PYX_XDEC_MEMVIEW(&__pyx_v_wo, 1);
    __pyx_v_wo = __pyx_t_6;
    __pyx_t_6.memview = NULL;
    __pyx_t_6.data = NULL;
 1639:             total_dipole_moments[i] = self.get_total_dipole_moment(wo)
    /* "water_algorithm_cython.pyx":1639
 *         for i from 0 <= i < N:
 *             wo = wos[i]
 *             total_dipole_moments[i] = self.get_total_dipole_moment(wo)             # <<<<<<<<<<<<<<
 *             if i % 1000 == 0:
 *                 print "Cython %i / %i" % (i, N)
 */
    __pyx_t_8 = ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_total_dipole_moment(__pyx_v_self, __pyx_v_wo, 0); if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = -1;
    __pyx_t_9.data = __pyx_v_total_dipole_moments.data;
    __pyx_t_9.memview = __pyx_v_total_dipole_moments.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
    {
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_total_dipole_moments.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_total_dipole_moments.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_total_dipole_moments.shape[1];
__pyx_t_9.strides[0] = __pyx_v_total_dipole_moments.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_t_8, __pyx_t_9, 1, 1, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
 1640:             if i % 1000 == 0:
    /* "water_algorithm_cython.pyx":1640
 *             wo = wos[i]
 *             total_dipole_moments[i] = self.get_total_dipole_moment(wo)
 *             if i % 1000 == 0:             # <<<<<<<<<<<<<<
 *                 print "Cython %i / %i" % (i, N)
 *         return total_dipole_moments.base
 */
    __pyx_t_10 = (__Pyx_mod_long(__pyx_v_i, 1000) == 0);
    if (__pyx_t_10) {
 1641:                 print "Cython %i / %i" % (i, N)
      /* "water_algorithm_cython.pyx":1641
 *             total_dipole_moments[i] = self.get_total_dipole_moment(wo)
 *             if i % 1000 == 0:
 *                 print "Cython %i / %i" % (i, N)             # <<<<<<<<<<<<<<
 *         return total_dipole_moments.base
 * 
 */
      __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_109), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
 1642:         return total_dipole_moments.base
  /* "water_algorithm_cython.pyx":1642
 *             if i % 1000 == 0:
 *                 print "Cython %i / %i" % (i, N)
 *         return total_dipole_moments.base             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_total_dipole_moments, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__base); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_total_dipole_moments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_wo, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_total_dipole_moments, 1);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_57get_total_dipole_moments(PyObject *__pyx_v_self, PyObject *__pyx_arg_wos); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_57get_total_dipole_moments(PyObject *__pyx_v_self, PyObject *__pyx_arg_wos) {
  __Pyx_memviewslice __pyx_v_wos = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_total_dipole_moments (wrapper)", 0);
  assert(__pyx_arg_wos); {
    __pyx_v_wos = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_arg_wos); if (unlikely(!__pyx_v_wos.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1633; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_total_dipole_moments", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_56get_total_dipole_moments(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_wos);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1643: 
 1644:     @cython.boundscheck(False)
 1645:     cpdef np.float_t[::1] get_total_dipole_moment(self, DTYPE2_t[::1] water_orientations):
/* "water_algorithm_cython.pyx":1645
 * 
 *     @cython.boundscheck(False)
 *     cpdef np.float_t[::1] get_total_dipole_moment(self, DTYPE2_t[::1] water_orientations):             # <<<<<<<<<<<<<<
 *         cdef np.float_t[::1] total_dipole_moment = np.array([0, 0, 0], dtype=DTYPE4)
 *         cdef unsigned int i, site, N = water_orientations.shape[0]
 */

static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_59get_total_dipole_moment(PyObject *__pyx_v_self, PyObject *__pyx_arg_water_orientations); /*proto*/
static __Pyx_memviewslice __pyx_f_22water_algorithm_cython_14WaterAlgorithm_get_total_dipole_moment(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_water_orientations, int __pyx_skip_dispatch) {
  __Pyx_memviewslice __pyx_v_total_dipole_moment = { 0, 0, { 0 }, { 0 }, { 0 } };
  unsigned int __pyx_v_i;
  unsigned int __pyx_v_site;
  unsigned int __pyx_v_N;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation;
  __Pyx_memviewslice __pyx_v_oxygen_positions = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_nearest_neighbors_nos = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_total_dipole_moment", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_110); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_59get_total_dipole_moment)) {
      if (unlikely(!__pyx_v_water_orientations.memview)) { __Pyx_RaiseUnboundLocalError("water_orientations"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
      __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_water_orientations, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_2);
      if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4.memview = NULL;
      __pyx_t_4.data = NULL;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

/* "water_algorithm_cython.pyx":1645
 * 
 *     @cython.boundscheck(False)
 *     cpdef np.float_t[::1] get_total_dipole_moment(self, DTYPE2_t[::1] water_orientations):             # <<<<<<<<<<<<<<
 *         cdef np.float_t[::1] total_dipole_moment = np.array([0, 0, 0], dtype=DTYPE4)
 *         cdef unsigned int i, site, N = water_orientations.shape[0]
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_58get_total_dipole_moment(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, __Pyx_memviewslice __pyx_v_water_orientations) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_total_dipole_moment", 0);
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_water_orientations.memview)) { __Pyx_RaiseUnboundLocalError("water_orientations"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __pyx_t_1 = ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_total_dipole_moment(__pyx_v_self, __pyx_v_water_orientations, 1); if (unlikely(!__pyx_t_1.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_t_1, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_total_dipole_moment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_water_orientations, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_61write_no_zeros(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_61write_no_zeros(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_nozeros = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_no_zeros (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__nozeros,0};
    PyObject* values[1] = {0};
    values[0] = __pyx_k_111;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nozeros);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_no_zeros") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_nozeros = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_no_zeros", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write_no_zeros", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_60write_no_zeros(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_nozeros);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1646:         cdef np.float_t[::1] total_dipole_moment = np.array([0, 0, 0], dtype=DTYPE4)
  /* "water_algorithm_cython.pyx":1646
 *     @cython.boundscheck(False)
 *     cpdef np.float_t[::1] get_total_dipole_moment(self, DTYPE2_t[::1] water_orientations):
 *         cdef np.float_t[::1] total_dipole_moment = np.array([0, 0, 0], dtype=DTYPE4)             # <<<<<<<<<<<<<<
 *         cdef unsigned int i, site, N = water_orientations.shape[0]
 *         cdef DTYPE2_t water_orientation
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_5numpy_float_t(__pyx_t_5);
  if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_total_dipole_moment = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
 1647:         cdef unsigned int i, site, N = water_orientations.shape[0]
  /* "water_algorithm_cython.pyx":1647
 *     cpdef np.float_t[::1] get_total_dipole_moment(self, DTYPE2_t[::1] water_orientations):
 *         cdef np.float_t[::1] total_dipole_moment = np.array([0, 0, 0], dtype=DTYPE4)
 *         cdef unsigned int i, site, N = water_orientations.shape[0]             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t water_orientation
 *         cdef np.float_t[:, ::1] oxygen_positions = self.oxygen_coordinates
 */
  __pyx_v_N = (__pyx_v_water_orientations.shape[0]);
 1648:         cdef DTYPE2_t water_orientation
 1649:         cdef np.float_t[:, ::1] oxygen_positions = self.oxygen_coordinates
  /* "water_algorithm_cython.pyx":1649
 *         cdef unsigned int i, site, N = water_orientations.shape[0]
 *         cdef DTYPE2_t water_orientation
 *         cdef np.float_t[:, ::1] oxygen_positions = self.oxygen_coordinates             # <<<<<<<<<<<<<<
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         for i from 0 <= i < N:
 */
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_float_t(((PyObject *)__pyx_v_self->oxygen_coordinates));
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_oxygen_positions = __pyx_t_7;
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
 1650:         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
  /* "water_algorithm_cython.pyx":1650
 *         cdef DTYPE2_t water_orientation
 *         cdef np.float_t[:, ::1] oxygen_positions = self.oxygen_coordinates
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < N:
 *             water_orientation = water_orientations[i]
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_5);
  if (unlikely(!__pyx_t_8.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_nearest_neighbors_nos = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
 1651:         for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":1651
 *         cdef np.float_t[:, ::1] oxygen_positions = self.oxygen_coordinates
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             water_orientation = water_orientations[i]
 *             site = i % 4
 */
  __pyx_t_9 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
 1652:             water_orientation = water_orientations[i]
    /* "water_algorithm_cython.pyx":1652
 *         cdef DTYPE_t[:, :, ::1] nearest_neighbors_nos = self.nearest_neighbors_nos
 *         for i from 0 <= i < N:
 *             water_orientation = water_orientations[i]             # <<<<<<<<<<<<<<
 *             site = i % 4
 *             total_dipole_moment = add_together(total_dipole_moment, self.get_single_molecule_dipole_moment(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos[0, i], nearest_neighbors_nos[1, i], nearest_neighbors_nos[2, i]))
 */
    __pyx_t_10 = __pyx_v_i;
    __pyx_v_water_orientation = (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_water_orientations.data) + __pyx_t_10)) )));
 1653:             site = i % 4
    /* "water_algorithm_cython.pyx":1653
 *         for i from 0 <= i < N:
 *             water_orientation = water_orientations[i]
 *             site = i % 4             # <<<<<<<<<<<<<<
 *             total_dipole_moment = add_together(total_dipole_moment, self.get_single_molecule_dipole_moment(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos[0, i], nearest_neighbors_nos[1, i], nearest_neighbors_nos[2, i]))
 *         return total_dipole_moment
 */
    __pyx_v_site = __Pyx_mod_long(__pyx_v_i, 4);
 1654:             total_dipole_moment = add_together(total_dipole_moment, self.get_single_molecule_dipole_moment(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos[0, i], nearest_neighbors_nos[1, i], nearest_neighbors_nos[2, i]))
    /* "water_algorithm_cython.pyx":1654
 *             water_orientation = water_orientations[i]
 *             site = i % 4
 *             total_dipole_moment = add_together(total_dipole_moment, self.get_single_molecule_dipole_moment(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos[0, i], nearest_neighbors_nos[1, i], nearest_neighbors_nos[2, i]))             # <<<<<<<<<<<<<<
 *         return total_dipole_moment
 * 
 */
    __pyx_t_12 = -1;
    __pyx_t_11.data = __pyx_v_nearest_neighbors_nos.data;
    __pyx_t_11.memview = __pyx_v_nearest_neighbors_nos.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_11, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_11.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

{
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[1];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[1];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_11.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_11.shape[0] = __pyx_v_nearest_neighbors_nos.shape[2];
__pyx_t_11.strides[0] = __pyx_v_nearest_neighbors_nos.strides[2];
    __pyx_t_11.suboffsets[0] = -1;

__pyx_t_12 = -1;
    __pyx_t_13.data = __pyx_v_nearest_neighbors_nos.data;
    __pyx_t_13.memview = __pyx_v_nearest_neighbors_nos.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_13, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_13.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

{
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[1];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[1];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_13.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_13.shape[0] = __pyx_v_nearest_neighbors_nos.shape[2];
__pyx_t_13.strides[0] = __pyx_v_nearest_neighbors_nos.strides[2];
    __pyx_t_13.suboffsets[0] = -1;

__pyx_t_12 = -1;
    __pyx_t_14.data = __pyx_v_nearest_neighbors_nos.data;
    __pyx_t_14.memview = __pyx_v_nearest_neighbors_nos.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_14, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 2;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_14.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

{
    Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_nearest_neighbors_nos.shape[1];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_nearest_neighbors_nos.strides[1];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 1)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_14.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_14.shape[0] = __pyx_v_nearest_neighbors_nos.shape[2];
__pyx_t_14.strides[0] = __pyx_v_nearest_neighbors_nos.strides[2];
    __pyx_t_14.suboffsets[0] = -1;

__pyx_t_15 = ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->get_single_molecule_dipole_moment(__pyx_v_self, __pyx_v_site, __pyx_v_water_orientation, __pyx_v_i, __pyx_v_oxygen_positions, __pyx_t_11, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
    __pyx_t_16 = __pyx_f_22water_algorithm_cython_add_together(__pyx_v_total_dipole_moment, __pyx_t_15); if (unlikely(!__pyx_t_16.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_v_total_dipole_moment, 1);
    __pyx_v_total_dipole_moment = __pyx_t_16;
    __pyx_t_16.memview = NULL;
    __pyx_t_16.data = NULL;
  }
 1655:         return total_dipole_moment
  /* "water_algorithm_cython.pyx":1655
 *             site = i % 4
 *             total_dipole_moment = add_together(total_dipole_moment, self.get_single_molecule_dipole_moment(site, water_orientation, i, oxygen_positions, nearest_neighbors_nos[0, i], nearest_neighbors_nos[1, i], nearest_neighbors_nos[2, i]))
 *         return total_dipole_moment             # <<<<<<<<<<<<<<
 * 
 *     def write_no_zeros(self, nozeros = False):
 */
  __PYX_INC_MEMVIEW(&__pyx_v_total_dipole_moment, 0);
  __pyx_r = __pyx_v_total_dipole_moment;
  goto __pyx_L0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_total_dipole_moment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_r;
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError,"Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_total_dipole_moment, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_oxygen_positions, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_nearest_neighbors_nos, 1);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_59get_total_dipole_moment(PyObject *__pyx_v_self, PyObject *__pyx_arg_water_orientations); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_59get_total_dipole_moment(PyObject *__pyx_v_self, PyObject *__pyx_arg_water_orientations) {
  __Pyx_memviewslice __pyx_v_water_orientations = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_total_dipole_moment (wrapper)", 0);
  assert(__pyx_arg_water_orientations); {
    __pyx_v_water_orientations = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_arg_water_orientations); if (unlikely(!__pyx_v_water_orientations.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_total_dipole_moment", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_58get_total_dipole_moment(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_water_orientations);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1656: 
 1657:     def write_no_zeros(self, nozeros = False):
/* "water_algorithm_cython.pyx":1657
 *         return total_dipole_moment
 * 
 *     def write_no_zeros(self, nozeros = False):             # <<<<<<<<<<<<<<
 *         from classification import Classification
 *         c = Classification(self, None)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_60write_no_zeros(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_nozeros) {
  PyObject *__pyx_v_Classification = NULL;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_v_no_zeros = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_no_zeros", 0);

  /* "water_algorithm_cython.pyx":1657
 *         return total_dipole_moment
 * 
 *     def write_no_zeros(self, nozeros = False):             # <<<<<<<<<<<<<<
 *         from classification import Classification
 *         c = Classification(self, None)
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_111 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
 1658:         from classification import Classification
  /* "water_algorithm_cython.pyx":1658
 * 
 *     def write_no_zeros(self, nozeros = False):
 *         from classification import Classification             # <<<<<<<<<<<<<<
 *         c = Classification(self, None)
 *         #cs = self.load_results(nozeros)
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Classification));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Classification));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Classification));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__classification), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s__Classification); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_Classification = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1659:         c = Classification(self, None)
  /* "water_algorithm_cython.pyx":1659
 *     def write_no_zeros(self, nozeros = False):
 *         from classification import Classification
 *         c = Classification(self, None)             # <<<<<<<<<<<<<<
 *         #cs = self.load_results(nozeros)
 *         no_zeros = c.remove_impossible_angles(cs)
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_INCREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
  __Pyx_GIVEREF(Py_None);
  __pyx_t_1 = PyObject_Call(__pyx_v_Classification, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_c = __pyx_t_1;
  __pyx_t_1 = 0;
 1660:         #cs = self.load_results(nozeros)
 1661:         no_zeros = c.remove_impossible_angles(cs)
  /* "water_algorithm_cython.pyx":1661
 *         c = Classification(self, None)
 *         #cs = self.load_results(nozeros)
 *         no_zeros = c.remove_impossible_angles(cs)             # <<<<<<<<<<<<<<
 *         np.savetxt(self.folder+"/nozero_results.txt", no_zeros.values())
 *         if not os.path.exists(self.folder+"/nozeros/"):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_112); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__cs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_no_zeros = __pyx_t_2;
  __pyx_t_2 = 0;
 1662:         np.savetxt(self.folder+"/nozero_results.txt", no_zeros.values())
  /* "water_algorithm_cython.pyx":1662
 *         #cs = self.load_results(nozeros)
 *         no_zeros = c.remove_impossible_angles(cs)
 *         np.savetxt(self.folder+"/nozero_results.txt", no_zeros.values())             # <<<<<<<<<<<<<<
 *         if not os.path.exists(self.folder+"/nozeros/"):
 *             os.makedirs(self.folder+"/nozeros/")
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__savetxt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(((PyObject *)__pyx_v_self->folder), ((PyObject *)__pyx_kp_s_113)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_no_zeros, __pyx_n_s__values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1663:         if not os.path.exists(self.folder+"/nozeros/"):
  /* "water_algorithm_cython.pyx":1663
 *         no_zeros = c.remove_impossible_angles(cs)
 *         np.savetxt(self.folder+"/nozero_results.txt", no_zeros.values())
 *         if not os.path.exists(self.folder+"/nozeros/"):             # <<<<<<<<<<<<<<
 *             os.makedirs(self.folder+"/nozeros/")
 *         write_results_to_file(self,  self.oxygen_coordinates, no_zeros.values(), self.cell,  self.nearest_neighbors_nos,  folder=self.folder+'/nozeros/')
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_self->folder), ((PyObject *)__pyx_kp_s_114)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = (!__pyx_t_5);
  if (__pyx_t_6) {
 1664:             os.makedirs(self.folder+"/nozeros/")
    /* "water_algorithm_cython.pyx":1664
 *         np.savetxt(self.folder+"/nozero_results.txt", no_zeros.values())
 *         if not os.path.exists(self.folder+"/nozeros/"):
 *             os.makedirs(self.folder+"/nozeros/")             # <<<<<<<<<<<<<<
 *         write_results_to_file(self,  self.oxygen_coordinates, no_zeros.values(), self.cell,  self.nearest_neighbors_nos,  folder=self.folder+'/nozeros/')
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__makedirs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_self->folder), ((PyObject *)__pyx_kp_s_114)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 1665:         write_results_to_file(self,  self.oxygen_coordinates, no_zeros.values(), self.cell,  self.nearest_neighbors_nos,  folder=self.folder+'/nozeros/')
  /* "water_algorithm_cython.pyx":1665
 *         if not os.path.exists(self.folder+"/nozeros/"):
 *             os.makedirs(self.folder+"/nozeros/")
 *         write_results_to_file(self,  self.oxygen_coordinates, no_zeros.values(), self.cell,  self.nearest_neighbors_nos,  folder=self.folder+'/nozeros/')             # <<<<<<<<<<<<<<
 * 
 *     def set_parameters(self, options):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_46); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_no_zeros, __pyx_n_s__values); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self->oxygen_coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_self->cell);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->cell);
  __Pyx_GIVEREF(__pyx_v_self->cell);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_v_self->folder), ((PyObject *)__pyx_kp_s_114)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__folder), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write_no_zeros", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Classification);
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XDECREF(__pyx_v_no_zeros);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_63set_parameters(PyObject *__pyx_v_self, PyObject *__pyx_v_options); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_63set_parameters(PyObject *__pyx_v_self, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_parameters (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_62set_parameters(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_options));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1666: 
 1667:     def set_parameters(self, options):
/* "water_algorithm_cython.pyx":1667
 *         write_results_to_file(self,  self.oxygen_coordinates, no_zeros.values(), self.cell,  self.nearest_neighbors_nos,  folder=self.folder+'/nozeros/')
 * 
 *     def set_parameters(self, options):             # <<<<<<<<<<<<<<
 *         if options is not None:
 *             self.write_geometries = options.write_geometries
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_62set_parameters(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_options) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_parameters", 0);
 1668:         if options is not None:
  /* "water_algorithm_cython.pyx":1668
 * 
 *     def set_parameters(self, options):
 *         if options is not None:             # <<<<<<<<<<<<<<
 *             self.write_geometries = options.write_geometries
 *             self.invariant_count = options.invariant_count
 */
  __pyx_t_1 = (__pyx_v_options != Py_None);
  if (__pyx_t_1) {
 1669:             self.write_geometries = options.write_geometries
    /* "water_algorithm_cython.pyx":1669
 *     def set_parameters(self, options):
 *         if options is not None:
 *             self.write_geometries = options.write_geometries             # <<<<<<<<<<<<<<
 *             self.invariant_count = options.invariant_count
 *             self.additional_atoms = options.additional_atoms
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__write_geometries); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->write_geometries);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->write_geometries));
    __pyx_v_self->write_geometries = ((PyBoolObject *)__pyx_t_2);
    __pyx_t_2 = 0;
 1670:             self.invariant_count = options.invariant_count
    /* "water_algorithm_cython.pyx":1670
 *         if options is not None:
 *             self.write_geometries = options.write_geometries
 *             self.invariant_count = options.invariant_count             # <<<<<<<<<<<<<<
 *             self.additional_atoms = options.additional_atoms
 *             self.vacuum = options.vacuum
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__invariant_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__invariant_count, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1671:             self.additional_atoms = options.additional_atoms
    /* "water_algorithm_cython.pyx":1671
 *             self.write_geometries = options.write_geometries
 *             self.invariant_count = options.invariant_count
 *             self.additional_atoms = options.additional_atoms             # <<<<<<<<<<<<<<
 *             self.vacuum = options.vacuum
 *             self.filename = options.filename
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__additional_atoms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__additional_atoms, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1672:             self.vacuum = options.vacuum
    /* "water_algorithm_cython.pyx":1672
 *             self.invariant_count = options.invariant_count
 *             self.additional_atoms = options.additional_atoms
 *             self.vacuum = options.vacuum             # <<<<<<<<<<<<<<
 *             self.filename = options.filename
 *             self.folder = options.folder
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__vacuum); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__vacuum, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1673:             self.filename = options.filename
    /* "water_algorithm_cython.pyx":1673
 *             self.additional_atoms = options.additional_atoms
 *             self.vacuum = options.vacuum
 *             self.filename = options.filename             # <<<<<<<<<<<<<<
 *             self.folder = options.folder
 *             self.periodic = self.handle_periodic_input(options.periodic)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->filename);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->filename));
    __pyx_v_self->filename = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
 1674:             self.folder = options.folder
    /* "water_algorithm_cython.pyx":1674
 *             self.vacuum = options.vacuum
 *             self.filename = options.filename
 *             self.folder = options.folder             # <<<<<<<<<<<<<<
 *             self.periodic = self.handle_periodic_input(options.periodic)
 *             self.y_offset = options.y_offset
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__folder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->folder);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->folder));
    __pyx_v_self->folder = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
 1675:             self.periodic = self.handle_periodic_input(options.periodic)
    /* "water_algorithm_cython.pyx":1675
 *             self.filename = options.filename
 *             self.folder = options.folder
 *             self.periodic = self.handle_periodic_input(options.periodic)             # <<<<<<<<<<<<<<
 *             self.y_offset = options.y_offset
 *             self.x_offset = options.x_offset
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__periodic); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1676:             self.y_offset = options.y_offset
    /* "water_algorithm_cython.pyx":1676
 *             self.folder = options.folder
 *             self.periodic = self.handle_periodic_input(options.periodic)
 *             self.y_offset = options.y_offset             # <<<<<<<<<<<<<<
 *             self.x_offset = options.x_offset
 *             self.z_offset = options.z_offset
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__y_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__y_offset, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1677:             self.x_offset = options.x_offset
    /* "water_algorithm_cython.pyx":1677
 *             self.periodic = self.handle_periodic_input(options.periodic)
 *             self.y_offset = options.y_offset
 *             self.x_offset = options.x_offset             # <<<<<<<<<<<<<<
 *             self.z_offset = options.z_offset
 *         else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__x_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__x_offset, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1678:             self.z_offset = options.z_offset
    /* "water_algorithm_cython.pyx":1678
 *             self.y_offset = options.y_offset
 *             self.x_offset = options.x_offset
 *             self.z_offset = options.z_offset             # <<<<<<<<<<<<<<
 *         else:
 *             self.x_offset = 0.0
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__z_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__z_offset, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 1679:         else:
 1680:             self.x_offset = 0.0
    /* "water_algorithm_cython.pyx":1680
 *             self.z_offset = options.z_offset
 *         else:
 *             self.x_offset = 0.0             # <<<<<<<<<<<<<<
 *             self.y_offset = 0.0
 *             self.z_offset = 0.0
 */
    __pyx_t_3 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__x_offset, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1681:             self.y_offset = 0.0
    /* "water_algorithm_cython.pyx":1681
 *         else:
 *             self.x_offset = 0.0
 *             self.y_offset = 0.0             # <<<<<<<<<<<<<<
 *             self.z_offset = 0.0
 * 
 */
    __pyx_t_3 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__y_offset, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1682:             self.z_offset = 0.0
    /* "water_algorithm_cython.pyx":1682
 *             self.x_offset = 0.0
 *             self.y_offset = 0.0
 *             self.z_offset = 0.0             # <<<<<<<<<<<<<<
 * 
 *     def execute_commands(self, options, args = None):
 */
    __pyx_t_3 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__z_offset, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.set_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_65execute_commands(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_65execute_commands(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_options = 0;
  PyObject *__pyx_v_args = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute_commands (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__options,&__pyx_n_s__args,0};
    PyObject* values[2] = {0,0};
 1683: 
 1684:     def execute_commands(self, options, args = None):
    /* "water_algorithm_cython.pyx":1684
 *             self.z_offset = 0.0
 * 
 *     def execute_commands(self, options, args = None):             # <<<<<<<<<<<<<<
 *         if options.wa_method != None:
 *             self.logfile = open(self.get_folder()+str(options.wa_method)+'_log%i.txt' % rank, 'w+')
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__options)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__args);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "execute_commands") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_options = values[0];
    __pyx_v_args = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("execute_commands", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.execute_commands", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_64execute_commands(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_options, __pyx_v_args);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_64execute_commands(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_options, PyObject *__pyx_v_args) {
  PyObject *__pyx_v_method = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("execute_commands", 0);
 1685:         if options.wa_method != None:
  /* "water_algorithm_cython.pyx":1685
 * 
 *     def execute_commands(self, options, args = None):
 *         if options.wa_method != None:             # <<<<<<<<<<<<<<
 *             self.logfile = open(self.get_folder()+str(options.wa_method)+'_log%i.txt' % rank, 'w+')
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__wa_method); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {
 1686:             self.logfile = open(self.get_folder()+str(options.wa_method)+'_log%i.txt' % rank, 'w+')
    /* "water_algorithm_cython.pyx":1686
 *     def execute_commands(self, options, args = None):
 *         if options.wa_method != None:
 *             self.logfile = open(self.get_folder()+str(options.wa_method)+'_log%i.txt' % rank, 'w+')             # <<<<<<<<<<<<<<
 * 
 *             if options.no_self_symmetry_groups:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__wa_method); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyInt_FromLong(rank); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_115), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Add(__pyx_t_4, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_116));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_kp_s_116));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_116));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->logfile);
    __Pyx_DECREF(__pyx_v_self->logfile);
    __pyx_v_self->logfile = __pyx_t_2;
    __pyx_t_2 = 0;
 1687: 
 1688:             if options.no_self_symmetry_groups:
    /* "water_algorithm_cython.pyx":1688
 *             self.logfile = open(self.get_folder()+str(options.wa_method)+'_log%i.txt' % rank, 'w+')
 * 
 *             if options.no_self_symmetry_groups:             # <<<<<<<<<<<<<<
 *                 self.save_self_symmetry_groups = False
 *             else:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s_117); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_3) {
 1689:                 self.save_self_symmetry_groups = False
      /* "water_algorithm_cython.pyx":1689
 * 
 *             if options.no_self_symmetry_groups:
 *                 self.save_self_symmetry_groups = False             # <<<<<<<<<<<<<<
 *             else:
 *                 self.save_self_symmetry_groups = True
 */
      __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_68, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L4;
    }
    /*else*/ {
 1690:             else:
 1691:                 self.save_self_symmetry_groups = True
      /* "water_algorithm_cython.pyx":1691
 *                 self.save_self_symmetry_groups = False
 *             else:
 *                 self.save_self_symmetry_groups = True             # <<<<<<<<<<<<<<
 * 
 *             method = getattr(self, str(options.wa_method))
 */
      __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_68, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L4:;
 1692: 
 1693:             method = getattr(self, str(options.wa_method))
    /* "water_algorithm_cython.pyx":1693
 *                 self.save_self_symmetry_groups = True
 * 
 *             method = getattr(self, str(options.wa_method))             # <<<<<<<<<<<<<<
 *             if args != None:
 *                 method(*args)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s__wa_method); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetAttr(((PyObject *)__pyx_v_self), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_method = __pyx_t_1;
    __pyx_t_1 = 0;
 1694:             if args != None:
    /* "water_algorithm_cython.pyx":1694
 * 
 *             method = getattr(self, str(options.wa_method))
 *             if args != None:             # <<<<<<<<<<<<<<
 *                 method(*args)
 *             else:
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_args, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {
 1695:                 method(*args)
      /* "water_algorithm_cython.pyx":1695
 *             method = getattr(self, str(options.wa_method))
 *             if args != None:
 *                 method(*args)             # <<<<<<<<<<<<<<
 *             else:
 *                 method()
 */
      __pyx_t_1 = PySequence_Tuple(__pyx_v_args); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
      __pyx_t_2 = PyObject_Call(__pyx_v_method, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L5;
    }
    /*else*/ {
 1696:             else:
 1697:                 method()
      /* "water_algorithm_cython.pyx":1697
 *                 method(*args)
 *             else:
 *                 method()             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_2 = PyObject_Call(__pyx_v_method, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __pyx_L5:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.execute_commands", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_method);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_67find_equivalent(PyObject *__pyx_v_self, PyObject *__pyx_v_filename); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_67find_equivalent(PyObject *__pyx_v_self, PyObject *__pyx_v_filename) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("find_equivalent (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_66find_equivalent(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_filename));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1698: 
 1699: 
 1700:     # Reverse engineering method
 1701:     def find_equivalent(self, filename):
/* "water_algorithm_cython.pyx":1701
 * 
 *     # Reverse engineering method
 *     def find_equivalent(self, filename):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[:, ::1] bond_variables
 *         oxygens_0 = self.atoms.copy()
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_66find_equivalent(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_filename) {
  __Pyx_memviewslice __pyx_v_bond_variables = { 0, 0, { 0 }, { 0 }, { 0 } };
  CYTHON_UNUSED PyObject *__pyx_v_oxygens_0 = NULL;
  PyObject *__pyx_v_atoms = NULL;
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_v_ivalues = NULL;
  PyObject *__pyx_v_ivectors = NULL;
  PyObject *__pyx_v_i2values = NULL;
  PyObject *__pyx_v_i2vectors = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_new_atoms = NULL;
  PyObject *__pyx_v_new_oxygens = NULL;
  PyObject *__pyx_v_maxvalue = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_selected_axis = NULL;
  PyObject *__pyx_v_evectors = NULL;
  PyObject *__pyx_v_equivalence = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_i2 = NULL;
  PyObject *__pyx_v_value2 = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_basis_1 = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_basis_2 = NULL;
  PyObject *__pyx_v_com = NULL;
  PyObject *__pyx_v_com2 = NULL;
  PyObject *__pyx_v_c1 = NULL;
  PyObject *__pyx_v_c2 = NULL;
  PyObject *__pyx_v_c3 = NULL;
  PyObject *__pyx_v_e = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_moi1 = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_moi2 = NULL;
  PyObject *__pyx_v_equals = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_cp = NULL;
  CYTHON_UNUSED int __pyx_v_loaded;
  PyObject *__pyx_v_bvv = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_elongated_bonds = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_elongated_hydrogen_bonds = NULL;
  PyObject *__pyx_v_water_orientations = NULL;
  int __pyx_v_nozeros;
  PyObject *__pyx_v_wos = NULL;
  struct __pyx_obj_19result_group_cython_ResultGroup *__pyx_v_rg = NULL;
  int __pyx_v_symmetry;
  PyObject *__pyx_v_wo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("find_equivalent", 0);
 1702:         cdef DTYPE2_t[:, ::1] bond_variables
 1703:         oxygens_0 = self.atoms.copy()
  /* "water_algorithm_cython.pyx":1703
 *     def find_equivalent(self, filename):
 *         cdef DTYPE2_t[:, ::1] bond_variables
 *         oxygens_0 = self.atoms.copy()             # <<<<<<<<<<<<<<
 *         atoms = ase.io.read(filename)
 *         oxygens = remove_hydrogens(atoms)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_oxygens_0 = __pyx_t_2;
  __pyx_t_2 = 0;
 1704:         atoms = ase.io.read(filename)
  /* "water_algorithm_cython.pyx":1704
 *         cdef DTYPE2_t[:, ::1] bond_variables
 *         oxygens_0 = self.atoms.copy()
 *         atoms = ase.io.read(filename)             # <<<<<<<<<<<<<<
 *         oxygens = remove_hydrogens(atoms)
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__io); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__read); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_atoms = __pyx_t_3;
  __pyx_t_3 = 0;
 1705:         oxygens = remove_hydrogens(atoms)
  /* "water_algorithm_cython.pyx":1705
 *         oxygens_0 = self.atoms.copy()
 *         atoms = ase.io.read(filename)
 *         oxygens = remove_hydrogens(atoms)             # <<<<<<<<<<<<<<
 * 
 *         ivalues, ivectors = get_moments_of_inertia(self.atoms)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__remove_hydrogens); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_atoms);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_atoms);
  __Pyx_GIVEREF(__pyx_v_atoms);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_oxygens = __pyx_t_2;
  __pyx_t_2 = 0;
 1706: 
 1707:         ivalues, ivectors = get_moments_of_inertia(self.atoms)
  /* "water_algorithm_cython.pyx":1707
 *         oxygens = remove_hydrogens(atoms)
 * 
 *         ivalues, ivectors = get_moments_of_inertia(self.atoms)             # <<<<<<<<<<<<<<
 *         i2values, i2vectors  = get_moments_of_inertia(oxygens)
 *         new_atoms = atoms.copy()
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_118); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->atoms);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->atoms);
  __Pyx_GIVEREF(__pyx_v_self->atoms);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_ivalues = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_ivectors = __pyx_t_2;
  __pyx_t_2 = 0;
 1708:         i2values, i2vectors  = get_moments_of_inertia(oxygens)
  /* "water_algorithm_cython.pyx":1708
 * 
 *         ivalues, ivectors = get_moments_of_inertia(self.atoms)
 *         i2values, i2vectors  = get_moments_of_inertia(oxygens)             # <<<<<<<<<<<<<<
 *         new_atoms = atoms.copy()
 *         new_oxygens = oxygens.copy()
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_118); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_oxygens);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_oxygens);
  __Pyx_GIVEREF(__pyx_v_oxygens);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_i2values = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_i2vectors = __pyx_t_3;
  __pyx_t_3 = 0;
 1709:         new_atoms = atoms.copy()
  /* "water_algorithm_cython.pyx":1709
 *         ivalues, ivectors = get_moments_of_inertia(self.atoms)
 *         i2values, i2vectors  = get_moments_of_inertia(oxygens)
 *         new_atoms = atoms.copy()             # <<<<<<<<<<<<<<
 *         new_oxygens = oxygens.copy()
 *         maxvalue = max(ivalues)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_atoms, __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_new_atoms = __pyx_t_3;
  __pyx_t_3 = 0;
 1710:         new_oxygens = oxygens.copy()
  /* "water_algorithm_cython.pyx":1710
 *         i2values, i2vectors  = get_moments_of_inertia(oxygens)
 *         new_atoms = atoms.copy()
 *         new_oxygens = oxygens.copy()             # <<<<<<<<<<<<<<
 *         maxvalue = max(ivalues)
 *         selected_axis = -1
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__copy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_new_oxygens = __pyx_t_1;
  __pyx_t_1 = 0;
 1711:         maxvalue = max(ivalues)
  /* "water_algorithm_cython.pyx":1711
 *         new_atoms = atoms.copy()
 *         new_oxygens = oxygens.copy()
 *         maxvalue = max(ivalues)             # <<<<<<<<<<<<<<
 *         selected_axis = -1
 *         evectors = np.zeros_like(i2vectors)
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_ivalues);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ivalues);
  __Pyx_GIVEREF(__pyx_v_ivalues);
  __pyx_t_3 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_maxvalue = __pyx_t_3;
  __pyx_t_3 = 0;
 1712:         selected_axis = -1
  /* "water_algorithm_cython.pyx":1712
 *         new_oxygens = oxygens.copy()
 *         maxvalue = max(ivalues)
 *         selected_axis = -1             # <<<<<<<<<<<<<<
 *         evectors = np.zeros_like(i2vectors)
 *         print ivectors
 */
  __Pyx_INCREF(__pyx_int_neg_1);
  __pyx_v_selected_axis = __pyx_int_neg_1;
 1713:         evectors = np.zeros_like(i2vectors)
  /* "water_algorithm_cython.pyx":1713
 *         maxvalue = max(ivalues)
 *         selected_axis = -1
 *         evectors = np.zeros_like(i2vectors)             # <<<<<<<<<<<<<<
 *         print ivectors
 *         print ivalues
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__zeros_like); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_i2vectors);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i2vectors);
  __Pyx_GIVEREF(__pyx_v_i2vectors);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_evectors = __pyx_t_2;
  __pyx_t_2 = 0;
 1714:         print ivectors
  /* "water_algorithm_cython.pyx":1714
 *         selected_axis = -1
 *         evectors = np.zeros_like(i2vectors)
 *         print ivectors             # <<<<<<<<<<<<<<
 *         print ivalues
 *         print i2vectors
 */
  if (__Pyx_PrintOne(0, __pyx_v_ivectors) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1715:         print ivalues
  /* "water_algorithm_cython.pyx":1715
 *         evectors = np.zeros_like(i2vectors)
 *         print ivectors
 *         print ivalues             # <<<<<<<<<<<<<<
 *         print i2vectors
 *         print i2values
 */
  if (__Pyx_PrintOne(0, __pyx_v_ivalues) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1716:         print i2vectors
  /* "water_algorithm_cython.pyx":1716
 *         print ivectors
 *         print ivalues
 *         print i2vectors             # <<<<<<<<<<<<<<
 *         print i2values
 *         equivalence = [-1, -1, -1]
 */
  if (__Pyx_PrintOne(0, __pyx_v_i2vectors) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1717:         print i2values
  /* "water_algorithm_cython.pyx":1717
 *         print ivalues
 *         print i2vectors
 *         print i2values             # <<<<<<<<<<<<<<
 *         equivalence = [-1, -1, -1]
 *         for i, value in enumerate(ivalues):
 */
  if (__Pyx_PrintOne(0, __pyx_v_i2values) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1718:         equivalence = [-1, -1, -1]
  /* "water_algorithm_cython.pyx":1718
 *         print i2vectors
 *         print i2values
 *         equivalence = [-1, -1, -1]             # <<<<<<<<<<<<<<
 *         for i, value in enumerate(ivalues):
 *             if value == maxvalue:
 */
  __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_neg_1);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  __Pyx_INCREF(__pyx_int_neg_1);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  __Pyx_INCREF(__pyx_int_neg_1);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  __pyx_v_equivalence = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
 1719:         for i, value in enumerate(ivalues):
  /* "water_algorithm_cython.pyx":1719
 *         print i2values
 *         equivalence = [-1, -1, -1]
 *         for i, value in enumerate(ivalues):             # <<<<<<<<<<<<<<
 *             if value == maxvalue:
 *                 selected_axis = i
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_2 = __pyx_int_0;
  if (PyList_CheckExact(__pyx_v_ivalues) || PyTuple_CheckExact(__pyx_v_ivalues)) {
    __pyx_t_3 = __pyx_v_ivalues; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ivalues); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_value);
    __pyx_v_value = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_2;
    __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;
 1720:             if value == maxvalue:
    /* "water_algorithm_cython.pyx":1720
 *         equivalence = [-1, -1, -1]
 *         for i, value in enumerate(ivalues):
 *             if value == maxvalue:             # <<<<<<<<<<<<<<
 *                 selected_axis = i
 *             for i2, value2 in enumerate(i2values):
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_v_maxvalue, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_8) {
 1721:                 selected_axis = i
      /* "water_algorithm_cython.pyx":1721
 *         for i, value in enumerate(ivalues):
 *             if value == maxvalue:
 *                 selected_axis = i             # <<<<<<<<<<<<<<
 *             for i2, value2 in enumerate(i2values):
 *                 print "%i and %i are equal?  %s" % (i, i2, are_equal(value, value2, error_tolerance=100))
 */
      __Pyx_INCREF(__pyx_v_i);
      __Pyx_DECREF(__pyx_v_selected_axis);
      __pyx_v_selected_axis = __pyx_v_i;
      goto __pyx_L9;
    }
    __pyx_L9:;
 1722:             for i2, value2 in enumerate(i2values):
    /* "water_algorithm_cython.pyx":1722
 *             if value == maxvalue:
 *                 selected_axis = i
 *             for i2, value2 in enumerate(i2values):             # <<<<<<<<<<<<<<
 *                 print "%i and %i are equal?  %s" % (i, i2, are_equal(value, value2, error_tolerance=100))
 *                 if are_equal(value, value2, error_tolerance=350) and i2 not in equivalence:
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (PyList_CheckExact(__pyx_v_i2values) || PyTuple_CheckExact(__pyx_v_i2values)) {
      __pyx_t_4 = __pyx_v_i2values; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_i2values); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_11 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_11 = __pyx_t_10(__pyx_t_4);
        if (unlikely(!__pyx_t_11)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_11);
      }
      __Pyx_XDECREF(__pyx_v_value2);
      __pyx_v_value2 = __pyx_t_11;
      __pyx_t_11 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_v_i2);
      __pyx_v_i2 = __pyx_t_1;
      __pyx_t_11 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_11;
      __pyx_t_11 = 0;
 1723:                 print "%i and %i are equal?  %s" % (i, i2, are_equal(value, value2, error_tolerance=100))
      /* "water_algorithm_cython.pyx":1723
 *                 selected_axis = i
 *             for i2, value2 in enumerate(i2values):
 *                 print "%i and %i are equal?  %s" % (i, i2, are_equal(value, value2, error_tolerance=100))             # <<<<<<<<<<<<<<
 *                 if are_equal(value, value2, error_tolerance=350) and i2 not in equivalence:
 *                     equivalence[i] = i2
 */
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__are_equal); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __Pyx_INCREF(__pyx_v_value2);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_value2);
      __Pyx_GIVEREF(__pyx_v_value2);
      __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_13));
      if (PyDict_SetItem(__pyx_t_13, ((PyObject *)__pyx_n_s__error_tolerance), __pyx_int_100) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_14 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_12), ((PyObject *)__pyx_t_13)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
      __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      __Pyx_INCREF(__pyx_v_i2);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_i2);
      __Pyx_GIVEREF(__pyx_v_i2);
      PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      __pyx_t_14 = 0;
      __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_119), ((PyObject *)__pyx_t_13)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_14));
      __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
      if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_14)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
 1724:                 if are_equal(value, value2, error_tolerance=350) and i2 not in equivalence:
      /* "water_algorithm_cython.pyx":1724
 *             for i2, value2 in enumerate(i2values):
 *                 print "%i and %i are equal?  %s" % (i, i2, are_equal(value, value2, error_tolerance=100))
 *                 if are_equal(value, value2, error_tolerance=350) and i2 not in equivalence:             # <<<<<<<<<<<<<<
 *                     equivalence[i] = i2
 *                     evectors[i] = i2vectors[i2]
 */
      __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s__are_equal); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_v_value);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_value);
      __Pyx_GIVEREF(__pyx_v_value);
      __Pyx_INCREF(__pyx_v_value2);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_value2);
      __Pyx_GIVEREF(__pyx_v_value2);
      __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_12));
      if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__error_tolerance), __pyx_int_350) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_13), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (__pyx_t_8) {
        __pyx_t_15 = (__Pyx_PySequence_Contains(__pyx_v_i2, ((PyObject *)__pyx_v_equivalence), Py_NE)); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_16 = __pyx_t_15;
      } else {
        __pyx_t_16 = __pyx_t_8;
      }
      if (__pyx_t_16) {
 1725:                     equivalence[i] = i2
        /* "water_algorithm_cython.pyx":1725
 *                 print "%i and %i are equal?  %s" % (i, i2, are_equal(value, value2, error_tolerance=100))
 *                 if are_equal(value, value2, error_tolerance=350) and i2 not in equivalence:
 *                     equivalence[i] = i2             # <<<<<<<<<<<<<<
 *                     evectors[i] = i2vectors[i2]
 *                     break
 */
        if (PyObject_SetItem(((PyObject *)__pyx_v_equivalence), __pyx_v_i, __pyx_v_i2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1726:                     evectors[i] = i2vectors[i2]
        /* "water_algorithm_cython.pyx":1726
 *                 if are_equal(value, value2, error_tolerance=350) and i2 not in equivalence:
 *                     equivalence[i] = i2
 *                     evectors[i] = i2vectors[i2]             # <<<<<<<<<<<<<<
 *                     break
 *         print equivalence
 */
        __pyx_t_11 = PyObject_GetItem(__pyx_v_i2vectors, __pyx_v_i2); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        if (PyObject_SetItem(__pyx_v_evectors, __pyx_v_i, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1726; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
 1727:                     break
        /* "water_algorithm_cython.pyx":1727
 *                     equivalence[i] = i2
 *                     evectors[i] = i2vectors[i2]
 *                     break             # <<<<<<<<<<<<<<
 *         print equivalence
 *         # find coordinates  in inertia basis for both
 */
        goto __pyx_L11_break;
        goto __pyx_L12;
      }
      __pyx_L12:;
    }
    __pyx_L11_break:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1728:         print equivalence
  /* "water_algorithm_cython.pyx":1728
 *                     evectors[i] = i2vectors[i2]
 *                     break
 *         print equivalence             # <<<<<<<<<<<<<<
 *         # find coordinates  in inertia basis for both
 *         basis_1 = np.reshape(ivectors, ivectors.size, order='F').reshape((3, 3))
 */
  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_equivalence)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1729:         # find coordinates  in inertia basis for both
 1730:         basis_1 = np.reshape(ivectors, ivectors.size, order='F').reshape((3, 3))
  /* "water_algorithm_cython.pyx":1730
 *         print equivalence
 *         # find coordinates  in inertia basis for both
 *         basis_1 = np.reshape(ivectors, ivectors.size, order='F').reshape((3, 3))             # <<<<<<<<<<<<<<
 *         basis_2 = np.reshape(evectors, evectors.size, order='F').reshape((3, 3))
 * 
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__reshape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ivectors, __pyx_n_s__size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_ivectors);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ivectors);
  __Pyx_GIVEREF(__pyx_v_ivectors);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__F)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__reshape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "water_algorithm_cython.pyx":1730
 *         print equivalence
 *         # find coordinates  in inertia basis for both
 *         basis_1 = np.reshape(ivectors, ivectors.size, order='F').reshape((3, 3))             # <<<<<<<<<<<<<<
 *         basis_2 = np.reshape(evectors, evectors.size, order='F').reshape((3, 3))
 * 
 */
  __pyx_k_tuple_120 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_3); if (unlikely(!__pyx_k_tuple_120)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_120);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_120));
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_121), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_basis_1 = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_k_tuple_121 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_120)); if (unlikely(!__pyx_k_tuple_121)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_121);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_121));
 1731:         basis_2 = np.reshape(evectors, evectors.size, order='F').reshape((3, 3))
  /* "water_algorithm_cython.pyx":1731
 *         # find coordinates  in inertia basis for both
 *         basis_1 = np.reshape(ivectors, ivectors.size, order='F').reshape((3, 3))
 *         basis_2 = np.reshape(evectors, evectors.size, order='F').reshape((3, 3))             # <<<<<<<<<<<<<<
 * 
 *         com = self.atoms.get_center_of_mass()
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__reshape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_evectors, __pyx_n_s__size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_evectors);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_evectors);
  __Pyx_GIVEREF(__pyx_v_evectors);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__F)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__reshape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "water_algorithm_cython.pyx":1731
 *         # find coordinates  in inertia basis for both
 *         basis_1 = np.reshape(ivectors, ivectors.size, order='F').reshape((3, 3))
 *         basis_2 = np.reshape(evectors, evectors.size, order='F').reshape((3, 3))             # <<<<<<<<<<<<<<
 * 
 *         com = self.atoms.get_center_of_mass()
 */
  __pyx_k_tuple_122 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_3); if (unlikely(!__pyx_k_tuple_122)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_122);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_122));
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_123), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_basis_2 = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_k_tuple_123 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_122)); if (unlikely(!__pyx_k_tuple_123)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_123);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_123));
 1732: 
 1733:         com = self.atoms.get_center_of_mass()
  /* "water_algorithm_cython.pyx":1733
 *         basis_2 = np.reshape(evectors, evectors.size, order='F').reshape((3, 3))
 * 
 *         com = self.atoms.get_center_of_mass()             # <<<<<<<<<<<<<<
 *         com2 = oxygens.get_center_of_mass()
 *         c1 = get_coordinates_in_basis(self.atoms.get_positions()-com, ivectors)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__get_center_of_mass); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_com = __pyx_t_4;
  __pyx_t_4 = 0;
 1734:         com2 = oxygens.get_center_of_mass()
  /* "water_algorithm_cython.pyx":1734
 * 
 *         com = self.atoms.get_center_of_mass()
 *         com2 = oxygens.get_center_of_mass()             # <<<<<<<<<<<<<<
 *         c1 = get_coordinates_in_basis(self.atoms.get_positions()-com, ivectors)
 *         c2 = get_coordinates_in_basis(oxygens.get_positions()-com2, i2vectors)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__get_center_of_mass); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_com2 = __pyx_t_3;
  __pyx_t_3 = 0;
 1735:         c1 = get_coordinates_in_basis(self.atoms.get_positions()-com, ivectors)
  /* "water_algorithm_cython.pyx":1735
 *         com = self.atoms.get_center_of_mass()
 *         com2 = oxygens.get_center_of_mass()
 *         c1 = get_coordinates_in_basis(self.atoms.get_positions()-com, ivectors)             # <<<<<<<<<<<<<<
 *         c2 = get_coordinates_in_basis(oxygens.get_positions()-com2, i2vectors)
 *         c2 = get_coordinates_in_basis(c2, ivectors)
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_124); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_v_com); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_ivectors);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_ivectors);
  __Pyx_GIVEREF(__pyx_v_ivectors);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_c1 = __pyx_t_4;
  __pyx_t_4 = 0;
 1736:         c2 = get_coordinates_in_basis(oxygens.get_positions()-com2, i2vectors)
  /* "water_algorithm_cython.pyx":1736
 *         com2 = oxygens.get_center_of_mass()
 *         c1 = get_coordinates_in_basis(self.atoms.get_positions()-com, ivectors)
 *         c2 = get_coordinates_in_basis(oxygens.get_positions()-com2, i2vectors)             # <<<<<<<<<<<<<<
 *         c2 = get_coordinates_in_basis(c2, ivectors)
 *         c3 = np.zeros_like(c2)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_124); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_3, __pyx_v_com2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_i2vectors);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_i2vectors);
  __Pyx_GIVEREF(__pyx_v_i2vectors);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_c2 = __pyx_t_1;
  __pyx_t_1 = 0;
 1737:         c2 = get_coordinates_in_basis(c2, ivectors)
  /* "water_algorithm_cython.pyx":1737
 *         c1 = get_coordinates_in_basis(self.atoms.get_positions()-com, ivectors)
 *         c2 = get_coordinates_in_basis(oxygens.get_positions()-com2, i2vectors)
 *         c2 = get_coordinates_in_basis(c2, ivectors)             # <<<<<<<<<<<<<<
 *         c3 = np.zeros_like(c2)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_124); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_c2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_c2);
  __Pyx_GIVEREF(__pyx_v_c2);
  __Pyx_INCREF(__pyx_v_ivectors);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_ivectors);
  __Pyx_GIVEREF(__pyx_v_ivectors);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_v_c2);
  __pyx_v_c2 = __pyx_t_4;
  __pyx_t_4 = 0;
 1738:         c3 = np.zeros_like(c2)
  /* "water_algorithm_cython.pyx":1738
 *         c2 = get_coordinates_in_basis(oxygens.get_positions()-com2, i2vectors)
 *         c2 = get_coordinates_in_basis(c2, ivectors)
 *         c3 = np.zeros_like(c2)             # <<<<<<<<<<<<<<
 * 
 *         for i, e in enumerate(equivalence):
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__zeros_like); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_c2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_c2);
  __Pyx_GIVEREF(__pyx_v_c2);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_c3 = __pyx_t_1;
  __pyx_t_1 = 0;
 1739: 
 1740:         for i, e in enumerate(equivalence):
  /* "water_algorithm_cython.pyx":1740
 *         c3 = np.zeros_like(c2)
 * 
 *         for i, e in enumerate(equivalence):             # <<<<<<<<<<<<<<
 *             c3[:,i] = c2[:,e]
 *         self.atoms.set_positions(c1)
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  __pyx_t_4 = ((PyObject *)__pyx_v_equivalence); __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
  for (;;) {
    if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF(__pyx_v_e);
    __pyx_v_e = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
 1741:             c3[:,i] = c2[:,e]
    /* "water_algorithm_cython.pyx":1741
 * 
 *         for i, e in enumerate(equivalence):
 *             c3[:,i] = c2[:,e]             # <<<<<<<<<<<<<<
 *         self.atoms.set_positions(c1)
 *         new_oxygens.set_positions(c3)
 */
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_k_slice_125);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_k_slice_125);
    __Pyx_GIVEREF(__pyx_k_slice_125);
    __Pyx_INCREF(__pyx_v_e);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_e);
    __Pyx_GIVEREF(__pyx_v_e);
    __pyx_t_2 = PyObject_GetItem(__pyx_v_c2, ((PyObject *)__pyx_t_3)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;

  /* "water_algorithm_cython.pyx":1741
 * 
 *         for i, e in enumerate(equivalence):
 *             c3[:,i] = c2[:,e]             # <<<<<<<<<<<<<<
 *         self.atoms.set_positions(c1)
 *         new_oxygens.set_positions(c3)
 */
  __pyx_k_slice_125 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_125)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_125);
  __Pyx_GIVEREF(__pyx_k_slice_125);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_k_slice_126);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_k_slice_126);
    __Pyx_GIVEREF(__pyx_k_slice_126);
    __Pyx_INCREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    if (PyObject_SetItem(__pyx_v_c3, ((PyObject *)__pyx_t_3), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_k_slice_126 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_126)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_126);
  __Pyx_GIVEREF(__pyx_k_slice_126);
 1742:         self.atoms.set_positions(c1)
  /* "water_algorithm_cython.pyx":1742
 *         for i, e in enumerate(equivalence):
 *             c3[:,i] = c2[:,e]
 *         self.atoms.set_positions(c1)             # <<<<<<<<<<<<<<
 *         new_oxygens.set_positions(c3)
 *         moi1 = get_moments_of_inertia(self.atoms)[1]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__set_positions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_c1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_c1);
  __Pyx_GIVEREF(__pyx_v_c1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1743:         new_oxygens.set_positions(c3)
  /* "water_algorithm_cython.pyx":1743
 *             c3[:,i] = c2[:,e]
 *         self.atoms.set_positions(c1)
 *         new_oxygens.set_positions(c3)             # <<<<<<<<<<<<<<
 *         moi1 = get_moments_of_inertia(self.atoms)[1]
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_oxygens, __pyx_n_s__set_positions); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_c3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_c3);
  __Pyx_GIVEREF(__pyx_v_c3);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1744:         moi1 = get_moments_of_inertia(self.atoms)[1]
  /* "water_algorithm_cython.pyx":1744
 *         self.atoms.set_positions(c1)
 *         new_oxygens.set_positions(c3)
 *         moi1 = get_moments_of_inertia(self.atoms)[1]             # <<<<<<<<<<<<<<
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]
 *         c1[:, 2] = -c1[:, 2]
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_118); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->atoms);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->atoms);
  __Pyx_GIVEREF(__pyx_v_self->atoms);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_moi1 = __pyx_t_4;
  __pyx_t_4 = 0;
 1745:         moi2 = get_moments_of_inertia(new_oxygens)[1]
  /* "water_algorithm_cython.pyx":1745
 *         new_oxygens.set_positions(c3)
 *         moi1 = get_moments_of_inertia(self.atoms)[1]
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]             # <<<<<<<<<<<<<<
 *         c1[:, 2] = -c1[:, 2]
 *         c1[:, 1] = c1[:, 1]
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_118); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_new_oxygens);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_new_oxygens);
  __Pyx_GIVEREF(__pyx_v_new_oxygens);
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_moi2 = __pyx_t_2;
  __pyx_t_2 = 0;
 1746:         c1[:, 2] = -c1[:, 2]
  /* "water_algorithm_cython.pyx":1746
 *         moi1 = get_moments_of_inertia(self.atoms)[1]
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]
 *         c1[:, 2] = -c1[:, 2]             # <<<<<<<<<<<<<<
 *         c1[:, 1] = c1[:, 1]
 *         #c1[:, 0] = -c1[:, 0]
 */
  __pyx_k_slice_127 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_127);
  __Pyx_GIVEREF(__pyx_k_slice_127);

  /* "water_algorithm_cython.pyx":1746
 *         moi1 = get_moments_of_inertia(self.atoms)[1]
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]
 *         c1[:, 2] = -c1[:, 2]             # <<<<<<<<<<<<<<
 *         c1[:, 1] = c1[:, 1]
 *         #c1[:, 0] = -c1[:, 0]
 */
  __pyx_t_2 = PyObject_GetItem(__pyx_v_c1, ((PyObject *)__pyx_k_tuple_128)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_k_tuple_128 = PyTuple_Pack(2, __pyx_k_slice_127, __pyx_int_2); if (unlikely(!__pyx_k_tuple_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_128);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_128));
  __pyx_k_slice_129 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_129)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_129);
  __Pyx_GIVEREF(__pyx_k_slice_129);
  if (PyObject_SetItem(__pyx_v_c1, ((PyObject *)__pyx_k_tuple_130), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_k_tuple_130 = PyTuple_Pack(2, __pyx_k_slice_129, __pyx_int_2); if (unlikely(!__pyx_k_tuple_130)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_130);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_130));
 1747:         c1[:, 1] = c1[:, 1]
  /* "water_algorithm_cython.pyx":1747
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]
 *         c1[:, 2] = -c1[:, 2]
 *         c1[:, 1] = c1[:, 1]             # <<<<<<<<<<<<<<
 *         #c1[:, 0] = -c1[:, 0]
 *         #closest_position = get_closest_position(c1[0], c2)
 */
  __pyx_k_slice_131 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_131)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_131);
  __Pyx_GIVEREF(__pyx_k_slice_131);

  /* "water_algorithm_cython.pyx":1747
 *         moi2 = get_moments_of_inertia(new_oxygens)[1]
 *         c1[:, 2] = -c1[:, 2]
 *         c1[:, 1] = c1[:, 1]             # <<<<<<<<<<<<<<
 *         #c1[:, 0] = -c1[:, 0]
 *         #closest_position = get_closest_position(c1[0], c2)
 */
  __pyx_t_1 = PyObject_GetItem(__pyx_v_c1, ((PyObject *)__pyx_k_tuple_132)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_k_tuple_132 = PyTuple_Pack(2, __pyx_k_slice_131, __pyx_int_1); if (unlikely(!__pyx_k_tuple_132)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_132);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_132));
  __pyx_k_slice_133 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_133)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_133);
  __Pyx_GIVEREF(__pyx_k_slice_133);
  if (PyObject_SetItem(__pyx_v_c1, ((PyObject *)__pyx_k_tuple_134), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_k_tuple_134 = PyTuple_Pack(2, __pyx_k_slice_133, __pyx_int_1); if (unlikely(!__pyx_k_tuple_134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_134);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_134));
 1748:         #c1[:, 0] = -c1[:, 0]
 1749:         #closest_position = get_closest_position(c1[0], c2)
 1750: 
 1751:         self.atoms.set_positions(c1)
  /* "water_algorithm_cython.pyx":1751
 *         #closest_position = get_closest_position(c1[0], c2)
 * 
 *         self.atoms.set_positions(c1)             # <<<<<<<<<<<<<<
 *         new_oxygens.set_positions(c3)
 *         #self.atoms = rotate_to(self.atoms, c1[0], closest_position)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->atoms, __pyx_n_s__set_positions); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_c1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_c1);
  __Pyx_GIVEREF(__pyx_v_c1);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1752:         new_oxygens.set_positions(c3)
  /* "water_algorithm_cython.pyx":1752
 * 
 *         self.atoms.set_positions(c1)
 *         new_oxygens.set_positions(c3)             # <<<<<<<<<<<<<<
 *         #self.atoms = rotate_to(self.atoms, c1[0], closest_position)
 *         ase.visualize.view(new_oxygens)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_oxygens, __pyx_n_s__set_positions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_c3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_c3);
  __Pyx_GIVEREF(__pyx_v_c3);
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1753:         #self.atoms = rotate_to(self.atoms, c1[0], closest_position)
 1754:         ase.visualize.view(new_oxygens)
  /* "water_algorithm_cython.pyx":1754
 *         new_oxygens.set_positions(c3)
 *         #self.atoms = rotate_to(self.atoms, c1[0], closest_position)
 *         ase.visualize.view(new_oxygens)             # <<<<<<<<<<<<<<
 *         ase.visualize.view(self.atoms)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__visualize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__view); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_new_oxygens);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_new_oxygens);
  __Pyx_GIVEREF(__pyx_v_new_oxygens);
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1755:         ase.visualize.view(self.atoms)
  /* "water_algorithm_cython.pyx":1755
 *         #self.atoms = rotate_to(self.atoms, c1[0], closest_position)
 *         ase.visualize.view(new_oxygens)
 *         ase.visualize.view(self.atoms)             # <<<<<<<<<<<<<<
 * 
 *         equals = get_equals(self.atoms, remove_hydrogens(new_oxygens).get_positions(), error_tolerance=1.2)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__visualize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__view); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_self->atoms);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->atoms);
  __Pyx_GIVEREF(__pyx_v_self->atoms);
  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1756: 
 1757:         equals = get_equals(self.atoms, remove_hydrogens(new_oxygens).get_positions(), error_tolerance=1.2)
  /* "water_algorithm_cython.pyx":1757
 *         ase.visualize.view(self.atoms)
 * 
 *         equals = get_equals(self.atoms, remove_hydrogens(new_oxygens).get_positions(), error_tolerance=1.2)             # <<<<<<<<<<<<<<
 *         cp = get_closest_positions(c1, c3)
 *         # dodecahedron hack
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_equals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__remove_hydrogens); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_new_oxygens);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_new_oxygens);
  __Pyx_GIVEREF(__pyx_v_new_oxygens);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->atoms);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->atoms);
  __Pyx_GIVEREF(__pyx_v_self->atoms);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = PyFloat_FromDouble(1.2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__error_tolerance), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_equals = __pyx_t_2;
  __pyx_t_2 = 0;
 1758:         cp = get_closest_positions(c1, c3)
  /* "water_algorithm_cython.pyx":1758
 * 
 *         equals = get_equals(self.atoms, remove_hydrogens(new_oxygens).get_positions(), error_tolerance=1.2)
 *         cp = get_closest_positions(c1, c3)             # <<<<<<<<<<<<<<
 *         # dodecahedron hack
 *         #equals = [19, 14, 18, 15, 9, 13, 5, 17, 10, 16, 4, 8, 0, 12, 6, 11, 3, 1, 7, 2]
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_135); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_c1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_c1);
  __Pyx_GIVEREF(__pyx_v_c1);
  __Pyx_INCREF(__pyx_v_c3);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_c3);
  __Pyx_GIVEREF(__pyx_v_c3);
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_cp = __pyx_t_4;
  __pyx_t_4 = 0;
 1759:         # dodecahedron hack
 1760:         #equals = [19, 14, 18, 15, 9, 13, 5, 17, 10, 16, 4, 8, 0, 12, 6, 11, 3, 1, 7, 2]
 1761:         #equals = [12, 17, 19, 16, 10, 6, 14, 18, 11, 4, 8, 15, 13, 5, 1, 3, 9, 7, 2, 0]
 1762:         # espp hack
 1763:         equals = [0, 8, 1, 7, 19, 4, 3, 17, 11, 16, 18, 5, 13, 14, 10, 15, 12, 6, 2, 9]
  /* "water_algorithm_cython.pyx":1763
 *         #equals = [12, 17, 19, 16, 10, 6, 14, 18, 11, 4, 8, 15, 13, 5, 1, 3, 9, 7, 2, 0]
 *         # espp hack
 *         equals = [0, 8, 1, 7, 19, 4, 3, 17, 11, 16, 18, 5, 13, 14, 10, 15, 12, 6, 2, 9]             # <<<<<<<<<<<<<<
 *         cdef int loaded = 0
 *         if equals != None:
 */
  __pyx_t_4 = PyList_New(20); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_0);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_8);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_8);
  __Pyx_GIVEREF(__pyx_int_8);
  __Pyx_INCREF(__pyx_int_1);
  PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  __Pyx_INCREF(__pyx_int_7);
  PyList_SET_ITEM(__pyx_t_4, 3, __pyx_int_7);
  __Pyx_GIVEREF(__pyx_int_7);
  __Pyx_INCREF(__pyx_int_19);
  PyList_SET_ITEM(__pyx_t_4, 4, __pyx_int_19);
  __Pyx_GIVEREF(__pyx_int_19);
  __Pyx_INCREF(__pyx_int_4);
  PyList_SET_ITEM(__pyx_t_4, 5, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __Pyx_INCREF(__pyx_int_3);
  PyList_SET_ITEM(__pyx_t_4, 6, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __Pyx_INCREF(__pyx_int_17);
  PyList_SET_ITEM(__pyx_t_4, 7, __pyx_int_17);
  __Pyx_GIVEREF(__pyx_int_17);
  __Pyx_INCREF(__pyx_int_11);
  PyList_SET_ITEM(__pyx_t_4, 8, __pyx_int_11);
  __Pyx_GIVEREF(__pyx_int_11);
  __Pyx_INCREF(__pyx_int_16);
  PyList_SET_ITEM(__pyx_t_4, 9, __pyx_int_16);
  __Pyx_GIVEREF(__pyx_int_16);
  __Pyx_INCREF(__pyx_int_18);
  PyList_SET_ITEM(__pyx_t_4, 10, __pyx_int_18);
  __Pyx_GIVEREF(__pyx_int_18);
  __Pyx_INCREF(__pyx_int_5);
  PyList_SET_ITEM(__pyx_t_4, 11, __pyx_int_5);
  __Pyx_GIVEREF(__pyx_int_5);
  __Pyx_INCREF(__pyx_int_13);
  PyList_SET_ITEM(__pyx_t_4, 12, __pyx_int_13);
  __Pyx_GIVEREF(__pyx_int_13);
  __Pyx_INCREF(__pyx_int_14);
  PyList_SET_ITEM(__pyx_t_4, 13, __pyx_int_14);
  __Pyx_GIVEREF(__pyx_int_14);
  __Pyx_INCREF(__pyx_int_10);
  PyList_SET_ITEM(__pyx_t_4, 14, __pyx_int_10);
  __Pyx_GIVEREF(__pyx_int_10);
  __Pyx_INCREF(__pyx_int_15);
  PyList_SET_ITEM(__pyx_t_4, 15, __pyx_int_15);
  __Pyx_GIVEREF(__pyx_int_15);
  __Pyx_INCREF(__pyx_int_12);
  PyList_SET_ITEM(__pyx_t_4, 16, __pyx_int_12);
  __Pyx_GIVEREF(__pyx_int_12);
  __Pyx_INCREF(__pyx_int_6);
  PyList_SET_ITEM(__pyx_t_4, 17, __pyx_int_6);
  __Pyx_GIVEREF(__pyx_int_6);
  __Pyx_INCREF(__pyx_int_2);
  PyList_SET_ITEM(__pyx_t_4, 18, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  __Pyx_INCREF(__pyx_int_9);
  PyList_SET_ITEM(__pyx_t_4, 19, __pyx_int_9);
  __Pyx_GIVEREF(__pyx_int_9);
  __Pyx_DECREF(__pyx_v_equals);
  __pyx_v_equals = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 1764:         cdef int loaded = 0
  /* "water_algorithm_cython.pyx":1764
 *         # espp hack
 *         equals = [0, 8, 1, 7, 19, 4, 3, 17, 11, 16, 18, 5, 13, 14, 10, 15, 12, 6, 2, 9]
 *         cdef int loaded = 0             # <<<<<<<<<<<<<<
 *         if equals != None:
 *             bvv, elongated_bonds, elongated_hydrogen_bonds = self.get_bond_varibles_from_atoms(atoms)
 */
  __pyx_v_loaded = 0;
 1765:         if equals != None:
  /* "water_algorithm_cython.pyx":1765
 *         equals = [0, 8, 1, 7, 19, 4, 3, 17, 11, 16, 18, 5, 13, 14, 10, 15, 12, 6, 2, 9]
 *         cdef int loaded = 0
 *         if equals != None:             # <<<<<<<<<<<<<<
 *             bvv, elongated_bonds, elongated_hydrogen_bonds = self.get_bond_varibles_from_atoms(atoms)
 *             water_orientations = self.get_water_orientations_from_bond_variables_and_molecule_change_matrix(bvv, equals)
 */
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_equals, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_16) {
 1766:             bvv, elongated_bonds, elongated_hydrogen_bonds = self.get_bond_varibles_from_atoms(atoms)
    /* "water_algorithm_cython.pyx":1766
 *         cdef int loaded = 0
 *         if equals != None:
 *             bvv, elongated_bonds, elongated_hydrogen_bonds = self.get_bond_varibles_from_atoms(atoms)             # <<<<<<<<<<<<<<
 *             water_orientations = self.get_water_orientations_from_bond_variables_and_molecule_change_matrix(bvv, equals)
 *             self.view_result(water_orientations)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_136); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_atoms);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_atoms);
    __Pyx_GIVEREF(__pyx_v_atoms);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_11)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L16_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_4)) goto __pyx_L16_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      index = 2; __pyx_t_1 = __pyx_t_5(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L16_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L17_unpacking_done;
      __pyx_L16_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L17_unpacking_done:;
    }
    __pyx_v_bvv = __pyx_t_3;
    __pyx_t_3 = 0;
    __pyx_v_elongated_bonds = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_v_elongated_hydrogen_bonds = __pyx_t_1;
    __pyx_t_1 = 0;
 1767:             water_orientations = self.get_water_orientations_from_bond_variables_and_molecule_change_matrix(bvv, equals)
    /* "water_algorithm_cython.pyx":1767
 *         if equals != None:
 *             bvv, elongated_bonds, elongated_hydrogen_bonds = self.get_bond_varibles_from_atoms(atoms)
 *             water_orientations = self.get_water_orientations_from_bond_variables_and_molecule_change_matrix(bvv, equals)             # <<<<<<<<<<<<<<
 *             self.view_result(water_orientations)
 *             nozeros = False
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_137); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_bvv);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bvv);
    __Pyx_GIVEREF(__pyx_v_bvv);
    __Pyx_INCREF(__pyx_v_equals);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_equals);
    __Pyx_GIVEREF(__pyx_v_equals);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_v_water_orientations = __pyx_t_4;
    __pyx_t_4 = 0;
 1768:             self.view_result(water_orientations)
    /* "water_algorithm_cython.pyx":1768
 *             bvv, elongated_bonds, elongated_hydrogen_bonds = self.get_bond_varibles_from_atoms(atoms)
 *             water_orientations = self.get_water_orientations_from_bond_variables_and_molecule_change_matrix(bvv, equals)
 *             self.view_result(water_orientations)             # <<<<<<<<<<<<<<
 *             nozeros = False
 *             wos = self.load_results(nozeros)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__view_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_water_orientations);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_water_orientations);
    __Pyx_GIVEREF(__pyx_v_water_orientations);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1769:             nozeros = False
    /* "water_algorithm_cython.pyx":1769
 *             water_orientations = self.get_water_orientations_from_bond_variables_and_molecule_change_matrix(bvv, equals)
 *             self.view_result(water_orientations)
 *             nozeros = False             # <<<<<<<<<<<<<<
 *             wos = self.load_results(nozeros)
 *             self.initialize_symmetry_operations()
 */
    __pyx_v_nozeros = 0;
 1770:             wos = self.load_results(nozeros)
    /* "water_algorithm_cython.pyx":1770
 *             self.view_result(water_orientations)
 *             nozeros = False
 *             wos = self.load_results(nozeros)             # <<<<<<<<<<<<<<
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__load_results); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_nozeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_v_wos = __pyx_t_1;
    __pyx_t_1 = 0;
 1771:             self.initialize_symmetry_operations()
    /* "water_algorithm_cython.pyx":1771
 *             nozeros = False
 *             wos = self.load_results(nozeros)
 *             self.initialize_symmetry_operations()             # <<<<<<<<<<<<<<
 *             self.load_invariants()
 *             self.result_group = ResultGroup(list(self.graph_invariants),  0)
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->initialize_symmetry_operations(__pyx_v_self);
 1772:             self.load_invariants()
    /* "water_algorithm_cython.pyx":1772
 *             wos = self.load_results(nozeros)
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()             # <<<<<<<<<<<<<<
 *             self.result_group = ResultGroup(list(self.graph_invariants),  0)
 *             self.print_time_stats()
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->load_invariants(__pyx_v_self);
 1773:             self.result_group = ResultGroup(list(self.graph_invariants),  0)
    /* "water_algorithm_cython.pyx":1773
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 *             self.result_group = ResultGroup(list(self.graph_invariants),  0)             # <<<<<<<<<<<<<<
 *             self.print_time_stats()
 *             self.do_initial_grouping(wos, 20, True)
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->graph_invariants));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->graph_invariants));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->graph_invariants));
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_19result_group_cython_ResultGroup)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->result_group);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
    __pyx_v_self->result_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_4);
    __pyx_t_4 = 0;
 1774:             self.print_time_stats()
    /* "water_algorithm_cython.pyx":1774
 *             self.load_invariants()
 *             self.result_group = ResultGroup(list(self.graph_invariants),  0)
 *             self.print_time_stats()             # <<<<<<<<<<<<<<
 *             self.do_initial_grouping(wos, 20, True)
 *             #bond_variables = get_bond_variables_3(water_orientations,  self.nearest_neighbors_nos)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__print_time_stats); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1775:             self.do_initial_grouping(wos, 20, True)
    /* "water_algorithm_cython.pyx":1775
 *             self.result_group = ResultGroup(list(self.graph_invariants),  0)
 *             self.print_time_stats()
 *             self.do_initial_grouping(wos, 20, True)             # <<<<<<<<<<<<<<
 *             #bond_variables = get_bond_variables_3(water_orientations,  self.nearest_neighbors_nos)
 *             rg = self.result_group.try_subgroups(bond_variables.base,  1)
 */
    if (!(likely(((__pyx_v_wos) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_wos, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->do_initial_grouping(__pyx_v_self, ((PyArrayObject *)__pyx_v_wos), 20, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1776:             #bond_variables = get_bond_variables_3(water_orientations,  self.nearest_neighbors_nos)
 1777:             rg = self.result_group.try_subgroups(bond_variables.base,  1)
    /* "water_algorithm_cython.pyx":1777
 *             self.do_initial_grouping(wos, 20, True)
 *             #bond_variables = get_bond_variables_3(water_orientations,  self.nearest_neighbors_nos)
 *             rg = self.result_group.try_subgroups(bond_variables.base,  1)             # <<<<<<<<<<<<<<
 *             print "Result groups has %i results" % len(rg.wos)
 *             self.finalize_grouping(rg)
 */
    if (unlikely(!__pyx_v_bond_variables.memview)) { __Pyx_RaiseUnboundLocalError("bond_variables"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_bond_variables, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = ((PyObject *)((struct __pyx_vtabstruct_19result_group_cython_ResultGroup *)__pyx_v_self->result_group->__pyx_vtab)->try_subgroups(__pyx_v_self->result_group, ((PyArrayObject *)__pyx_t_4), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_rg = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_1);
    __pyx_t_1 = 0;
 1778:             print "Result groups has %i results" % len(rg.wos)
    /* "water_algorithm_cython.pyx":1778
 *             #bond_variables = get_bond_variables_3(water_orientations,  self.nearest_neighbors_nos)
 *             rg = self.result_group.try_subgroups(bond_variables.base,  1)
 *             print "Result groups has %i results" % len(rg.wos)             # <<<<<<<<<<<<<<
 *             self.finalize_grouping(rg)
 *             bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_rg->wos);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_6 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_138), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 1779:             self.finalize_grouping(rg)
    /* "water_algorithm_cython.pyx":1779
 *             rg = self.result_group.try_subgroups(bond_variables.base,  1)
 *             print "Result groups has %i results" % len(rg.wos)
 *             self.finalize_grouping(rg)             # <<<<<<<<<<<<<<
 *             bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *             symmetry = self.is_symmetric_with_another_result(rg,  water_orientations, -1, True, self.symmetry_operations, -1, [], False, [], None, bond_variables)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__finalize_grouping); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_rg));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_rg));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_rg));
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1780:             bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":1780
 *             print "Result groups has %i results" % len(rg.wos)
 *             self.finalize_grouping(rg)
 *             bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *             symmetry = self.is_symmetric_with_another_result(rg,  water_orientations, -1, True, self.symmetry_operations, -1, [], False, [], None, bond_variables)
 * 
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_int_4);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_4);
    __Pyx_GIVEREF(__pyx_int_4);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
    if (unlikely(!__pyx_t_17.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
    __pyx_v_bond_variables = __pyx_t_17;
    __pyx_t_17.memview = NULL;
    __pyx_t_17.data = NULL;
 1781:             symmetry = self.is_symmetric_with_another_result(rg,  water_orientations, -1, True, self.symmetry_operations, -1, [], False, [], None, bond_variables)
    /* "water_algorithm_cython.pyx":1781
 *             self.finalize_grouping(rg)
 *             bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *             symmetry = self.is_symmetric_with_another_result(rg,  water_orientations, -1, True, self.symmetry_operations, -1, [], False, [], None, bond_variables)             # <<<<<<<<<<<<<<
 * 
 *             assert symmetry != None
 */
    __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_water_orientations);
    if (unlikely(!__pyx_t_18.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = ((PyObject *)__pyx_v_self->symmetry_operations);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_symmetry = ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->is_symmetric_with_another_result(__pyx_v_self, __pyx_v_rg, __pyx_t_18, -1, 1, ((PyObject*)__pyx_t_4), -1, ((PyObject*)__pyx_t_1), 0, ((PyObject*)__pyx_t_2), ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)Py_None), __pyx_v_bond_variables);
    __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
 1782: 
 1783:             assert symmetry != None
    /* "water_algorithm_cython.pyx":1783
 *             symmetry = self.is_symmetric_with_another_result(rg,  water_orientations, -1, True, self.symmetry_operations, -1, [], False, [], None, bond_variables)
 * 
 *             assert symmetry != None             # <<<<<<<<<<<<<<
 *             for i, wo in enumerate(wos):
 *                 if all(np.equal(wo, symmetry)):
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_symmetry); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_16)) {
      PyErr_SetNone(PyExc_AssertionError);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
 1784:             for i, wo in enumerate(wos):
    /* "water_algorithm_cython.pyx":1784
 * 
 *             assert symmetry != None
 *             for i, wo in enumerate(wos):             # <<<<<<<<<<<<<<
 *                 if all(np.equal(wo, symmetry)):
 *                     print "Structure is symmetric with structure number %i" % i
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    if (PyList_CheckExact(__pyx_v_wos) || PyTuple_CheckExact(__pyx_v_wos)) {
      __pyx_t_2 = __pyx_v_wos; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_wos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_4 = __pyx_t_7(__pyx_t_2);
        if (unlikely(!__pyx_t_4)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF(__pyx_v_wo);
      __pyx_v_wo = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_1;
      __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_4;
      __pyx_t_4 = 0;
 1785:                 if all(np.equal(wo, symmetry)):
      /* "water_algorithm_cython.pyx":1785
 *             assert symmetry != None
 *             for i, wo in enumerate(wos):
 *                 if all(np.equal(wo, symmetry)):             # <<<<<<<<<<<<<<
 *                     print "Structure is symmetric with structure number %i" % i
 * 
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__equal); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_symmetry); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_wo);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_wo);
      __Pyx_GIVEREF(__pyx_v_wo);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_builtin_all, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_16 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_16) {
 1786:                     print "Structure is symmetric with structure number %i" % i
        /* "water_algorithm_cython.pyx":1786
 *             for i, wo in enumerate(wos):
 *                 if all(np.equal(wo, symmetry)):
 *                     print "Structure is symmetric with structure number %i" % i             # <<<<<<<<<<<<<<
 * 
 *     def verify_results(self):
 */
        __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_139), __pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_4));
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
        goto __pyx_L20;
      }
      __pyx_L20:;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L15;
  }
  __pyx_L15:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.find_equivalent", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
  __Pyx_XDECREF(__pyx_v_oxygens_0);
  __Pyx_XDECREF(__pyx_v_atoms);
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XDECREF(__pyx_v_ivalues);
  __Pyx_XDECREF(__pyx_v_ivectors);
  __Pyx_XDECREF(__pyx_v_i2values);
  __Pyx_XDECREF(__pyx_v_i2vectors);
  __Pyx_XDECREF(__pyx_v_new_atoms);
  __Pyx_XDECREF(__pyx_v_new_oxygens);
  __Pyx_XDECREF(__pyx_v_maxvalue);
  __Pyx_XDECREF(__pyx_v_selected_axis);
  __Pyx_XDECREF(__pyx_v_evectors);
  __Pyx_XDECREF(__pyx_v_equivalence);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_i2);
  __Pyx_XDECREF(__pyx_v_value2);
  __Pyx_XDECREF(__pyx_v_basis_1);
  __Pyx_XDECREF(__pyx_v_basis_2);
  __Pyx_XDECREF(__pyx_v_com);
  __Pyx_XDECREF(__pyx_v_com2);
  __Pyx_XDECREF(__pyx_v_c1);
  __Pyx_XDECREF(__pyx_v_c2);
  __Pyx_XDECREF(__pyx_v_c3);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_moi1);
  __Pyx_XDECREF(__pyx_v_moi2);
  __Pyx_XDECREF(__pyx_v_equals);
  __Pyx_XDECREF(__pyx_v_cp);
  __Pyx_XDECREF(__pyx_v_bvv);
  __Pyx_XDECREF(__pyx_v_elongated_bonds);
  __Pyx_XDECREF(__pyx_v_elongated_hydrogen_bonds);
  __Pyx_XDECREF(__pyx_v_water_orientations);
  __Pyx_XDECREF(__pyx_v_wos);
  __Pyx_XDECREF((PyObject *)__pyx_v_rg);
  __Pyx_XDECREF(__pyx_v_wo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_69verify_results(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_69verify_results(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("verify_results (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_68verify_results(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1787: 
 1788:     def verify_results(self):
/* "water_algorithm_cython.pyx":1788
 *                     print "Structure is symmetric with structure number %i" % i
 * 
 *     def verify_results(self):             # <<<<<<<<<<<<<<
 *         nozeros = False
 *         wos = self.load_results(nozeros)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_68verify_results(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  int __pyx_v_nozeros;
  PyObject *__pyx_v_wos = NULL;
  CYTHON_UNUSED struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *__pyx_v_symm = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("verify_results", 0);
 1789:         nozeros = False
  /* "water_algorithm_cython.pyx":1789
 * 
 *     def verify_results(self):
 *         nozeros = False             # <<<<<<<<<<<<<<
 *         wos = self.load_results(nozeros)
 *         self.initialize_symmetry_operations()
 */
  __pyx_v_nozeros = 0;
 1790:         wos = self.load_results(nozeros)
  /* "water_algorithm_cython.pyx":1790
 *     def verify_results(self):
 *         nozeros = False
 *         wos = self.load_results(nozeros)             # <<<<<<<<<<<<<<
 *         self.initialize_symmetry_operations()
 *         #wo = np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3], dtype=DTYPE2)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__load_results); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_nozeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_wos = __pyx_t_2;
  __pyx_t_2 = 0;
 1791:         self.initialize_symmetry_operations()
  /* "water_algorithm_cython.pyx":1791
 *         nozeros = False
 *         wos = self.load_results(nozeros)
 *         self.initialize_symmetry_operations()             # <<<<<<<<<<<<<<
 *         #wo = np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3], dtype=DTYPE2)
 *         cdef SymmetryOperation symm = self.symmetry_operations[2]
 */
  ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->initialize_symmetry_operations(__pyx_v_self);
 1792:         #wo = np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3], dtype=DTYPE2)
 1793:         cdef SymmetryOperation symm = self.symmetry_operations[2]
  /* "water_algorithm_cython.pyx":1793
 *         self.initialize_symmetry_operations()
 *         #wo = np.array([0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3], dtype=DTYPE2)
 *         cdef SymmetryOperation symm = self.symmetry_operations[2]             # <<<<<<<<<<<<<<
 * 
 *         self.load_invariants()
 */
  if (unlikely(((PyObject *)__pyx_v_self->symmetry_operations) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  if (!(likely(((PyList_GET_ITEM(__pyx_v_self->symmetry_operations, 2)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_self->symmetry_operations, 2), __pyx_ptype_10symmetries_25symmetry_operation_cython_SymmetryOperation))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyList_GET_ITEM(__pyx_v_self->symmetry_operations, 2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_symm = ((struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_t_2);
  __pyx_t_2 = 0;
 1794: 
 1795:         self.load_invariants()
  /* "water_algorithm_cython.pyx":1795
 *         cdef SymmetryOperation symm = self.symmetry_operations[2]
 * 
 *         self.load_invariants()             # <<<<<<<<<<<<<<
 *         self.result_group = ResultGroup(list(self.graph_invariants),  0)
 *         self.print_time_stats()
 */
  ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->load_invariants(__pyx_v_self);
 1796:         self.result_group = ResultGroup(list(self.graph_invariants),  0)
  /* "water_algorithm_cython.pyx":1796
 * 
 *         self.load_invariants()
 *         self.result_group = ResultGroup(list(self.graph_invariants),  0)             # <<<<<<<<<<<<<<
 *         self.print_time_stats()
 *         #self.remove_symmetries_no_invariants(wos,   self.nearest_neighbors_nos, self.N-1, self.symmetry_operations, [], False)
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->graph_invariants));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->graph_invariants));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->graph_invariants));
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_19result_group_cython_ResultGroup)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->result_group);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->result_group));
  __pyx_v_self->result_group = ((struct __pyx_obj_19result_group_cython_ResultGroup *)__pyx_t_3);
  __pyx_t_3 = 0;
 1797:         self.print_time_stats()
  /* "water_algorithm_cython.pyx":1797
 *         self.load_invariants()
 *         self.result_group = ResultGroup(list(self.graph_invariants),  0)
 *         self.print_time_stats()             # <<<<<<<<<<<<<<
 *         #self.remove_symmetries_no_invariants(wos,   self.nearest_neighbors_nos, self.N-1, self.symmetry_operations, [], False)
 *         self.remove_symmetric_results(wos, self.N-1, self.symmetry_operations, len(self.graph_invariants), [], False, [], None, 20, True)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__print_time_stats); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1798:         #self.remove_symmetries_no_invariants(wos,   self.nearest_neighbors_nos, self.N-1, self.symmetry_operations, [], False)
 1799:         self.remove_symmetric_results(wos, self.N-1, self.symmetry_operations, len(self.graph_invariants), [], False, [], None, 20, True)
  /* "water_algorithm_cython.pyx":1799
 *         self.print_time_stats()
 *         #self.remove_symmetries_no_invariants(wos,   self.nearest_neighbors_nos, self.N-1, self.symmetry_operations, [], False)
 *         self.remove_symmetric_results(wos, self.N-1, self.symmetry_operations, len(self.graph_invariants), [], False, [], None, 20, True)             # <<<<<<<<<<<<<<
 *         #self.remove_symmetric_results(wos, -1, self.symmetry_operations)
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_wos);
  if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((PyObject *)__pyx_v_self->symmetry_operations);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = ((PyObject *)__pyx_v_self->graph_invariants);
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyList_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((PyObject *)((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->remove_symmetric_results(__pyx_v_self, __pyx_t_4, (__pyx_v_self->N - 1), ((PyObject*)__pyx_t_2), __pyx_t_5, ((PyObject*)__pyx_t_3), 0, ((PyObject*)__pyx_t_1), ((struct __pyx_obj_10symmetries_26self_symmetry_group_cython_SelfSymmetryGroup *)Py_None), 20, 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.verify_results", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wos);
  __Pyx_XDECREF((PyObject *)__pyx_v_symm);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_71get_bond_varibles_from_atoms(PyObject *__pyx_v_self, PyObject *__pyx_v_atoms); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_71get_bond_varibles_from_atoms(PyObject *__pyx_v_self, PyObject *__pyx_v_atoms) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bond_varibles_from_atoms (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_70get_bond_varibles_from_atoms(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_atoms));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1800:         #self.remove_symmetric_results(wos, -1, self.symmetry_operations)
 1801: 
 1802: 
 1803: 
 1804:     def get_bond_varibles_from_atoms(self, atoms):
/* "water_algorithm_cython.pyx":1804
 * 
 * 
 *     def get_bond_varibles_from_atoms(self, atoms):             # <<<<<<<<<<<<<<
 *         oxygens = remove_hydrogens(atoms)
 *         nearest_hydrogens = {}
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_70get_bond_varibles_from_atoms(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_atoms) {
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_v_nearest_hydrogens = NULL;
  int __pyx_v_elongated_bonds;
  int __pyx_v_elongated_hydrogen_bonds;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_atom = NULL;
  PyObject *__pyx_v_smallest_distance = NULL;
  PyObject *__pyx_v_smallest_distance_oxygen = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_axis_to_closest_oxygen = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_oxygen = NULL;
  PyObject *__pyx_v_distance = NULL;
  PyObject *__pyx_v_periodic_distances = NULL;
  PyObject *__pyx_v_axis = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_periodic_distance = NULL;
  PyObject *__pyx_v_bond_variables = NULL;
  PyObject *__pyx_v_nearest_hydrogens_o = NULL;
  PyObject *__pyx_v_hydrogen_no = NULL;
  PyObject *__pyx_v_second_closest_oxygen = NULL;
  PyObject *__pyx_v_axis_to_second_closest_oxygen = NULL;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_opposite_periodicity_axis;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bond_varibles_from_atoms", 0);
 1805:         oxygens = remove_hydrogens(atoms)
  /* "water_algorithm_cython.pyx":1805
 * 
 *     def get_bond_varibles_from_atoms(self, atoms):
 *         oxygens = remove_hydrogens(atoms)             # <<<<<<<<<<<<<<
 *         nearest_hydrogens = {}
 *         elongated_bonds = False
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__remove_hydrogens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_atoms);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_atoms);
  __Pyx_GIVEREF(__pyx_v_atoms);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_oxygens = __pyx_t_3;
  __pyx_t_3 = 0;
 1806:         nearest_hydrogens = {}
  /* "water_algorithm_cython.pyx":1806
 *     def get_bond_varibles_from_atoms(self, atoms):
 *         oxygens = remove_hydrogens(atoms)
 *         nearest_hydrogens = {}             # <<<<<<<<<<<<<<
 *         elongated_bonds = False
 *         elongated_hydrogen_bonds = False
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_nearest_hydrogens = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
 1807:         elongated_bonds = False
  /* "water_algorithm_cython.pyx":1807
 *         oxygens = remove_hydrogens(atoms)
 *         nearest_hydrogens = {}
 *         elongated_bonds = False             # <<<<<<<<<<<<<<
 *         elongated_hydrogen_bonds = False
 *         for i, atom in enumerate(atoms):
 */
  __pyx_v_elongated_bonds = 0;
 1808:         elongated_hydrogen_bonds = False
  /* "water_algorithm_cython.pyx":1808
 *         nearest_hydrogens = {}
 *         elongated_bonds = False
 *         elongated_hydrogen_bonds = False             # <<<<<<<<<<<<<<
 *         for i, atom in enumerate(atoms):
 *             if atom.get_symbol() == 'H':
 */
  __pyx_v_elongated_hydrogen_bonds = 0;
 1809:         for i, atom in enumerate(atoms):
  /* "water_algorithm_cython.pyx":1809
 *         elongated_bonds = False
 *         elongated_hydrogen_bonds = False
 *         for i, atom in enumerate(atoms):             # <<<<<<<<<<<<<<
 *             if atom.get_symbol() == 'H':
 *                 smallest_distance = None
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  if (PyList_CheckExact(__pyx_v_atoms) || PyTuple_CheckExact(__pyx_v_atoms)) {
    __pyx_t_2 = __pyx_v_atoms; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_atoms); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_atom);
    __pyx_v_atom = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_3;
    __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
 1810:             if atom.get_symbol() == 'H':
    /* "water_algorithm_cython.pyx":1810
 *         elongated_hydrogen_bonds = False
 *         for i, atom in enumerate(atoms):
 *             if atom.get_symbol() == 'H':             # <<<<<<<<<<<<<<
 *                 smallest_distance = None
 *                 smallest_distance_oxygen = -1
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s__get_symbol); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, ((PyObject *)__pyx_n_s__H), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_7) {
 1811:                 smallest_distance = None
      /* "water_algorithm_cython.pyx":1811
 *         for i, atom in enumerate(atoms):
 *             if atom.get_symbol() == 'H':
 *                 smallest_distance = None             # <<<<<<<<<<<<<<
 *                 smallest_distance_oxygen = -1
 *                 axis_to_closest_oxygen = -1
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF(__pyx_v_smallest_distance);
      __pyx_v_smallest_distance = Py_None;
 1812:                 smallest_distance_oxygen = -1
      /* "water_algorithm_cython.pyx":1812
 *             if atom.get_symbol() == 'H':
 *                 smallest_distance = None
 *                 smallest_distance_oxygen = -1             # <<<<<<<<<<<<<<
 *                 axis_to_closest_oxygen = -1
 *                 for j, oxygen in enumerate(oxygens):
 */
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_XDECREF(__pyx_v_smallest_distance_oxygen);
      __pyx_v_smallest_distance_oxygen = __pyx_int_neg_1;
 1813:                 axis_to_closest_oxygen = -1
      /* "water_algorithm_cython.pyx":1813
 *                 smallest_distance = None
 *                 smallest_distance_oxygen = -1
 *                 axis_to_closest_oxygen = -1             # <<<<<<<<<<<<<<
 *                 for j, oxygen in enumerate(oxygens):
 *                     distance = np.linalg.norm(oxygen.get_position() - atom.get_position())
 */
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_XDECREF(__pyx_v_axis_to_closest_oxygen);
      __pyx_v_axis_to_closest_oxygen = __pyx_int_neg_1;
 1814:                 for j, oxygen in enumerate(oxygens):
      /* "water_algorithm_cython.pyx":1814
 *                 smallest_distance_oxygen = -1
 *                 axis_to_closest_oxygen = -1
 *                 for j, oxygen in enumerate(oxygens):             # <<<<<<<<<<<<<<
 *                     distance = np.linalg.norm(oxygen.get_position() - atom.get_position())
 *                     if smallest_distance == None or distance < smallest_distance:
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_1 = __pyx_int_0;
      if (PyList_CheckExact(__pyx_v_oxygens) || PyTuple_CheckExact(__pyx_v_oxygens)) {
        __pyx_t_6 = __pyx_v_oxygens; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_oxygens); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
      }
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
          if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_10 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
          if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_10); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_10 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          __pyx_t_10 = __pyx_t_9(__pyx_t_6);
          if (unlikely(!__pyx_t_10)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_XDECREF(__pyx_v_oxygen);
        __pyx_v_oxygen = __pyx_t_10;
        __pyx_t_10 = 0;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_XDECREF(__pyx_v_j);
        __pyx_v_j = __pyx_t_1;
        __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1);
        __pyx_t_1 = __pyx_t_10;
        __pyx_t_10 = 0;
 1815:                     distance = np.linalg.norm(oxygen.get_position() - atom.get_position())
        /* "water_algorithm_cython.pyx":1815
 *                 axis_to_closest_oxygen = -1
 *                 for j, oxygen in enumerate(oxygens):
 *                     distance = np.linalg.norm(oxygen.get_position() - atom.get_position())             # <<<<<<<<<<<<<<
 *                     if smallest_distance == None or distance < smallest_distance:
 *                         smallest_distance = distance
 */
        __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__linalg); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s__norm); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygen, __pyx_n_s__get_position); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s__get_position); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_13 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Subtract(__pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_v_distance);
        __pyx_v_distance = __pyx_t_11;
        __pyx_t_11 = 0;
 1816:                     if smallest_distance == None or distance < smallest_distance:
        /* "water_algorithm_cython.pyx":1816
 *                 for j, oxygen in enumerate(oxygens):
 *                     distance = np.linalg.norm(oxygen.get_position() - atom.get_position())
 *                     if smallest_distance == None or distance < smallest_distance:             # <<<<<<<<<<<<<<
 *                         smallest_distance = distance
 *                         smallest_distance_oxygen = j
 */
        __pyx_t_11 = PyObject_RichCompare(__pyx_v_smallest_distance, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (!__pyx_t_7) {
          __pyx_t_11 = PyObject_RichCompare(__pyx_v_distance, __pyx_v_smallest_distance, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_15 = __pyx_t_14;
        } else {
          __pyx_t_15 = __pyx_t_7;
        }
        if (__pyx_t_15) {
 1817:                         smallest_distance = distance
          /* "water_algorithm_cython.pyx":1817
 *                     distance = np.linalg.norm(oxygen.get_position() - atom.get_position())
 *                     if smallest_distance == None or distance < smallest_distance:
 *                         smallest_distance = distance             # <<<<<<<<<<<<<<
 *                         smallest_distance_oxygen = j
 *                         axis_to_closest_oxygen = 13
 */
          __Pyx_INCREF(__pyx_v_distance);
          __Pyx_DECREF(__pyx_v_smallest_distance);
          __pyx_v_smallest_distance = __pyx_v_distance;
 1818:                         smallest_distance_oxygen = j
          /* "water_algorithm_cython.pyx":1818
 *                     if smallest_distance == None or distance < smallest_distance:
 *                         smallest_distance = distance
 *                         smallest_distance_oxygen = j             # <<<<<<<<<<<<<<
 *                         axis_to_closest_oxygen = 13
 *                     if self.periodic:
 */
          __Pyx_INCREF(__pyx_v_j);
          __Pyx_DECREF(__pyx_v_smallest_distance_oxygen);
          __pyx_v_smallest_distance_oxygen = __pyx_v_j;
 1819:                         axis_to_closest_oxygen = 13
          /* "water_algorithm_cython.pyx":1819
 *                         smallest_distance = distance
 *                         smallest_distance_oxygen = j
 *                         axis_to_closest_oxygen = 13             # <<<<<<<<<<<<<<
 *                     if self.periodic:
 *                         assert self.cell != None
 */
          __Pyx_INCREF(__pyx_int_13);
          __Pyx_DECREF(__pyx_v_axis_to_closest_oxygen);
          __pyx_v_axis_to_closest_oxygen = __pyx_int_13;
          goto __pyx_L8;
        }
        __pyx_L8:;
 1820:                     if self.periodic:
        /* "water_algorithm_cython.pyx":1820
 *                         smallest_distance_oxygen = j
 *                         axis_to_closest_oxygen = 13
 *                     if self.periodic:             # <<<<<<<<<<<<<<
 *                         assert self.cell != None
 *                         periodic_distances, axis = get_periodic_distances(atom.get_position(), oxygen.get_position(), self.cell)
 */
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (__pyx_t_15) {
 1821:                         assert self.cell != None
          /* "water_algorithm_cython.pyx":1821
 *                         axis_to_closest_oxygen = 13
 *                     if self.periodic:
 *                         assert self.cell != None             # <<<<<<<<<<<<<<
 *                         periodic_distances, axis = get_periodic_distances(atom.get_position(), oxygen.get_position(), self.cell)
 *                         for k, periodic_distance in enumerate(periodic_distances):
 */
          #ifndef CYTHON_WITHOUT_ASSERTIONS
          __pyx_t_11 = PyObject_RichCompare(__pyx_v_self->cell, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_15)) {
            PyErr_SetNone(PyExc_AssertionError);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #endif
 1822:                         periodic_distances, axis = get_periodic_distances(atom.get_position(), oxygen.get_position(), self.cell)
          /* "water_algorithm_cython.pyx":1822
 *                     if self.periodic:
 *                         assert self.cell != None
 *                         periodic_distances, axis = get_periodic_distances(atom.get_position(), oxygen.get_position(), self.cell)             # <<<<<<<<<<<<<<
 *                         for k, periodic_distance in enumerate(periodic_distances):
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 */
          __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_140); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_atom, __pyx_n_s__get_position); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_10 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygen, __pyx_n_s__get_position); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_12 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_v_self->cell);
          PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_self->cell);
          __Pyx_GIVEREF(__pyx_v_self->cell);
          __pyx_t_10 = 0;
          __pyx_t_12 = 0;
          __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
          if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
            PyObject* sequence = __pyx_t_12;
            #if CYTHON_COMPILING_IN_CPYTHON
            Py_ssize_t size = Py_SIZE(sequence);
            #else
            Py_ssize_t size = PySequence_Size(sequence);
            #endif
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            #if CYTHON_COMPILING_IN_CPYTHON
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_13 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_13 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_11);
            #else
            __pyx_t_13 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_11);
            #endif
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          {
            Py_ssize_t index = -1;
            __pyx_t_10 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_16 = Py_TYPE(__pyx_t_10)->tp_iternext;
            index = 0; __pyx_t_13 = __pyx_t_16(__pyx_t_10); if (unlikely(!__pyx_t_13)) goto __pyx_L10_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_13);
            index = 1; __pyx_t_11 = __pyx_t_16(__pyx_t_10); if (unlikely(!__pyx_t_11)) goto __pyx_L10_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_11);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_16 = NULL;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L11_unpacking_done;
            __pyx_L10_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_16 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_L11_unpacking_done:;
          }
          __Pyx_XDECREF(__pyx_v_periodic_distances);
          __pyx_v_periodic_distances = __pyx_t_13;
          __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_v_axis);
          __pyx_v_axis = __pyx_t_11;
          __pyx_t_11 = 0;
 1823:                         for k, periodic_distance in enumerate(periodic_distances):
          /* "water_algorithm_cython.pyx":1823
 *                         assert self.cell != None
 *                         periodic_distances, axis = get_periodic_distances(atom.get_position(), oxygen.get_position(), self.cell)
 *                         for k, periodic_distance in enumerate(periodic_distances):             # <<<<<<<<<<<<<<
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 *                                 axis_to_closest_oxygen = axis[k]
 */
          __Pyx_INCREF(__pyx_int_0);
          __pyx_t_12 = __pyx_int_0;
          if (PyList_CheckExact(__pyx_v_periodic_distances) || PyTuple_CheckExact(__pyx_v_periodic_distances)) {
            __pyx_t_11 = __pyx_v_periodic_distances; __Pyx_INCREF(__pyx_t_11); __pyx_t_17 = 0;
            __pyx_t_18 = NULL;
          } else {
            __pyx_t_17 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_periodic_distances); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_18 = Py_TYPE(__pyx_t_11)->tp_iternext;
          }
          for (;;) {
            if (!__pyx_t_18 && PyList_CheckExact(__pyx_t_11)) {
              if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_11)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_13 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_17); __Pyx_INCREF(__pyx_t_13); __pyx_t_17++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #else
              __pyx_t_13 = PySequence_ITEM(__pyx_t_11, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #endif
            } else if (!__pyx_t_18 && PyTuple_CheckExact(__pyx_t_11)) {
              if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_17); __Pyx_INCREF(__pyx_t_13); __pyx_t_17++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #else
              __pyx_t_13 = PySequence_ITEM(__pyx_t_11, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #endif
            } else {
              __pyx_t_13 = __pyx_t_18(__pyx_t_11);
              if (unlikely(!__pyx_t_13)) {
                if (PyErr_Occurred()) {
                  if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
                  else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_13);
            }
            __Pyx_XDECREF(__pyx_v_periodic_distance);
            __pyx_v_periodic_distance = __pyx_t_13;
            __pyx_t_13 = 0;
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_XDECREF(__pyx_v_k);
            __pyx_v_k = __pyx_t_12;
            __pyx_t_13 = PyNumber_Add(__pyx_t_12, __pyx_int_1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_12);
            __pyx_t_12 = __pyx_t_13;
            __pyx_t_13 = 0;
 1824:                             if smallest_distance == None or periodic_distance < smallest_distance:
            /* "water_algorithm_cython.pyx":1824
 *                         periodic_distances, axis = get_periodic_distances(atom.get_position(), oxygen.get_position(), self.cell)
 *                         for k, periodic_distance in enumerate(periodic_distances):
 *                             if smallest_distance == None or periodic_distance < smallest_distance:             # <<<<<<<<<<<<<<
 *                                 axis_to_closest_oxygen = axis[k]
 *                                 smallest_distance = periodic_distance
 */
            __pyx_t_13 = PyObject_RichCompare(__pyx_v_smallest_distance, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (!__pyx_t_15) {
              __pyx_t_13 = PyObject_RichCompare(__pyx_v_periodic_distance, __pyx_v_smallest_distance, Py_LT); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __pyx_t_14 = __pyx_t_7;
            } else {
              __pyx_t_14 = __pyx_t_15;
            }
            if (__pyx_t_14) {
 1825:                                 axis_to_closest_oxygen = axis[k]
              /* "water_algorithm_cython.pyx":1825
 *                         for k, periodic_distance in enumerate(periodic_distances):
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 *                                 axis_to_closest_oxygen = axis[k]             # <<<<<<<<<<<<<<
 *                                 smallest_distance = periodic_distance
 *                                 smallest_distance_oxygen = j
 */
              __pyx_t_13 = PyObject_GetItem(__pyx_v_axis, __pyx_v_k); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_v_axis_to_closest_oxygen);
              __pyx_v_axis_to_closest_oxygen = __pyx_t_13;
              __pyx_t_13 = 0;
 1826:                                 smallest_distance = periodic_distance
              /* "water_algorithm_cython.pyx":1826
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 *                                 axis_to_closest_oxygen = axis[k]
 *                                 smallest_distance = periodic_distance             # <<<<<<<<<<<<<<
 *                                 smallest_distance_oxygen = j
 *                 if smallest_distance_oxygen not in nearest_hydrogens:
 */
              __Pyx_INCREF(__pyx_v_periodic_distance);
              __Pyx_DECREF(__pyx_v_smallest_distance);
              __pyx_v_smallest_distance = __pyx_v_periodic_distance;
 1827:                                 smallest_distance_oxygen = j
              /* "water_algorithm_cython.pyx":1827
 *                                 axis_to_closest_oxygen = axis[k]
 *                                 smallest_distance = periodic_distance
 *                                 smallest_distance_oxygen = j             # <<<<<<<<<<<<<<
 *                 if smallest_distance_oxygen not in nearest_hydrogens:
 *                     nearest_hydrogens[smallest_distance_oxygen] = []
 */
              __Pyx_INCREF(__pyx_v_j);
              __Pyx_DECREF(__pyx_v_smallest_distance_oxygen);
              __pyx_v_smallest_distance_oxygen = __pyx_v_j;
              goto __pyx_L14;
            }
            __pyx_L14:;
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1828:                 if smallest_distance_oxygen not in nearest_hydrogens:
      /* "water_algorithm_cython.pyx":1828
 *                                 smallest_distance = periodic_distance
 *                                 smallest_distance_oxygen = j
 *                 if smallest_distance_oxygen not in nearest_hydrogens:             # <<<<<<<<<<<<<<
 *                     nearest_hydrogens[smallest_distance_oxygen] = []
 *                 if smallest_distance > 1.15:
 */
      __pyx_t_14 = (__Pyx_PyDict_Contains(__pyx_v_smallest_distance_oxygen, ((PyObject *)__pyx_v_nearest_hydrogens), Py_NE)); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_14) {
 1829:                     nearest_hydrogens[smallest_distance_oxygen] = []
        /* "water_algorithm_cython.pyx":1829
 *                                 smallest_distance_oxygen = j
 *                 if smallest_distance_oxygen not in nearest_hydrogens:
 *                     nearest_hydrogens[smallest_distance_oxygen] = []             # <<<<<<<<<<<<<<
 *                 if smallest_distance > 1.15:
 *                     elongated_bonds = True
 */
        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(((PyObject *)__pyx_v_nearest_hydrogens), __pyx_v_smallest_distance_oxygen, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        goto __pyx_L15;
      }
      __pyx_L15:;
 1830:                 if smallest_distance > 1.15:
      /* "water_algorithm_cython.pyx":1830
 *                 if smallest_distance_oxygen not in nearest_hydrogens:
 *                     nearest_hydrogens[smallest_distance_oxygen] = []
 *                 if smallest_distance > 1.15:             # <<<<<<<<<<<<<<
 *                     elongated_bonds = True
 *                 nearest_hydrogens[smallest_distance_oxygen].append(i)
 */
      __pyx_t_1 = PyFloat_FromDouble(1.15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyObject_RichCompare(__pyx_v_smallest_distance, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_14) {
 1831:                     elongated_bonds = True
        /* "water_algorithm_cython.pyx":1831
 *                     nearest_hydrogens[smallest_distance_oxygen] = []
 *                 if smallest_distance > 1.15:
 *                     elongated_bonds = True             # <<<<<<<<<<<<<<
 *                 nearest_hydrogens[smallest_distance_oxygen].append(i)
 * 
 */
        __pyx_v_elongated_bonds = 1;
        goto __pyx_L16;
      }
      __pyx_L16:;
 1832:                 nearest_hydrogens[smallest_distance_oxygen].append(i)
      /* "water_algorithm_cython.pyx":1832
 *                 if smallest_distance > 1.15:
 *                     elongated_bonds = True
 *                 nearest_hydrogens[smallest_distance_oxygen].append(i)             # <<<<<<<<<<<<<<
 * 
 *         # Get the bond variables by first finding the second closest oxygen to the closest hydrogen
 */
      __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_nearest_hydrogens), __pyx_v_smallest_distance_oxygen); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_t_6, __pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1833: 
 1834:         # Get the bond variables by first finding the second closest oxygen to the closest hydrogen
 1835:         bond_variables = {}
  /* "water_algorithm_cython.pyx":1835
 * 
 *         # Get the bond variables by first finding the second closest oxygen to the closest hydrogen
 *         bond_variables = {}             # <<<<<<<<<<<<<<
 *         for i in nearest_hydrogens:
 *             nearest_hydrogens_o = nearest_hydrogens[i]
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_v_bond_variables = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
 1836:         for i in nearest_hydrogens:
  /* "water_algorithm_cython.pyx":1836
 *         # Get the bond variables by first finding the second closest oxygen to the closest hydrogen
 *         bond_variables = {}
 *         for i in nearest_hydrogens:             # <<<<<<<<<<<<<<
 *             nearest_hydrogens_o = nearest_hydrogens[i]
 *             if i not in bond_variables:
 */
  __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_dict_iterator(((PyObject *)__pyx_v_nearest_hydrogens), 1, ((PyObject *)NULL), (&__pyx_t_8), (&__pyx_t_19)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __pyx_t_3 = __pyx_t_2;
  __pyx_t_2 = 0;
  while (1) {
    __pyx_t_20 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_8, &__pyx_t_4, &__pyx_t_2, NULL, NULL, __pyx_t_19);
    if (unlikely(__pyx_t_20 == 0)) break;
    if (unlikely(__pyx_t_20 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_2;
    __pyx_t_2 = 0;
 1837:             nearest_hydrogens_o = nearest_hydrogens[i]
    /* "water_algorithm_cython.pyx":1837
 *         bond_variables = {}
 *         for i in nearest_hydrogens:
 *             nearest_hydrogens_o = nearest_hydrogens[i]             # <<<<<<<<<<<<<<
 *             if i not in bond_variables:
 *                 bond_variables[i] = {}
 */
    __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_nearest_hydrogens), __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_v_nearest_hydrogens_o);
    __pyx_v_nearest_hydrogens_o = __pyx_t_2;
    __pyx_t_2 = 0;
 1838:             if i not in bond_variables:
    /* "water_algorithm_cython.pyx":1838
 *         for i in nearest_hydrogens:
 *             nearest_hydrogens_o = nearest_hydrogens[i]
 *             if i not in bond_variables:             # <<<<<<<<<<<<<<
 *                 bond_variables[i] = {}
 *             for hydrogen_no in nearest_hydrogens_o:
 */
    __pyx_t_14 = (__Pyx_PyDict_Contains(__pyx_v_i, ((PyObject *)__pyx_v_bond_variables), Py_NE)); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_14) {
 1839:                 bond_variables[i] = {}
      /* "water_algorithm_cython.pyx":1839
 *             nearest_hydrogens_o = nearest_hydrogens[i]
 *             if i not in bond_variables:
 *                 bond_variables[i] = {}             # <<<<<<<<<<<<<<
 *             for hydrogen_no in nearest_hydrogens_o:
 *                 smallest_distance = None # to second closest oxygen
 */
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      if (PyDict_SetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      goto __pyx_L19;
    }
    __pyx_L19:;
 1840:             for hydrogen_no in nearest_hydrogens_o:
    /* "water_algorithm_cython.pyx":1840
 *             if i not in bond_variables:
 *                 bond_variables[i] = {}
 *             for hydrogen_no in nearest_hydrogens_o:             # <<<<<<<<<<<<<<
 *                 smallest_distance = None # to second closest oxygen
 *                 second_closest_oxygen = -1
 */
    if (PyList_CheckExact(__pyx_v_nearest_hydrogens_o) || PyTuple_CheckExact(__pyx_v_nearest_hydrogens_o)) {
      __pyx_t_2 = __pyx_v_nearest_hydrogens_o; __Pyx_INCREF(__pyx_t_2); __pyx_t_17 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_17 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_nearest_hydrogens_o); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_17); __Pyx_INCREF(__pyx_t_1); __pyx_t_17++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_17); __Pyx_INCREF(__pyx_t_1); __pyx_t_17++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_17); __pyx_t_17++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_5(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_hydrogen_no);
      __pyx_v_hydrogen_no = __pyx_t_1;
      __pyx_t_1 = 0;
 1841:                 smallest_distance = None # to second closest oxygen
      /* "water_algorithm_cython.pyx":1841
 *                 bond_variables[i] = {}
 *             for hydrogen_no in nearest_hydrogens_o:
 *                 smallest_distance = None # to second closest oxygen             # <<<<<<<<<<<<<<
 *                 second_closest_oxygen = -1
 *                 axis_to_second_closest_oxygen = -1
 */
      __Pyx_INCREF(Py_None);
      __Pyx_XDECREF(__pyx_v_smallest_distance);
      __pyx_v_smallest_distance = Py_None;
 1842:                 second_closest_oxygen = -1
      /* "water_algorithm_cython.pyx":1842
 *             for hydrogen_no in nearest_hydrogens_o:
 *                 smallest_distance = None # to second closest oxygen
 *                 second_closest_oxygen = -1             # <<<<<<<<<<<<<<
 *                 axis_to_second_closest_oxygen = -1
 *                 for j, oxygen in enumerate(oxygens):
 */
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_XDECREF(__pyx_v_second_closest_oxygen);
      __pyx_v_second_closest_oxygen = __pyx_int_neg_1;
 1843:                 axis_to_second_closest_oxygen = -1
      /* "water_algorithm_cython.pyx":1843
 *                 smallest_distance = None # to second closest oxygen
 *                 second_closest_oxygen = -1
 *                 axis_to_second_closest_oxygen = -1             # <<<<<<<<<<<<<<
 *                 for j, oxygen in enumerate(oxygens):
 *                     if i != j:
 */
      __Pyx_INCREF(__pyx_int_neg_1);
      __Pyx_XDECREF(__pyx_v_axis_to_second_closest_oxygen);
      __pyx_v_axis_to_second_closest_oxygen = __pyx_int_neg_1;
 1844:                 for j, oxygen in enumerate(oxygens):
      /* "water_algorithm_cython.pyx":1844
 *                 second_closest_oxygen = -1
 *                 axis_to_second_closest_oxygen = -1
 *                 for j, oxygen in enumerate(oxygens):             # <<<<<<<<<<<<<<
 *                     if i != j:
 *                         distance = np.linalg.norm(atoms[hydrogen_no].get_position()-oxygens.get_positions()[j])
 */
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_1 = __pyx_int_0;
      if (PyList_CheckExact(__pyx_v_oxygens) || PyTuple_CheckExact(__pyx_v_oxygens)) {
        __pyx_t_6 = __pyx_v_oxygens; __Pyx_INCREF(__pyx_t_6); __pyx_t_21 = 0;
        __pyx_t_9 = NULL;
      } else {
        __pyx_t_21 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_oxygens); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext;
      }
      for (;;) {
        if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_6)) {
          if (__pyx_t_21 >= PyList_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_12 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_21); __Pyx_INCREF(__pyx_t_12); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_6, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) {
          if (__pyx_t_21 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_21); __Pyx_INCREF(__pyx_t_12); __pyx_t_21++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_12 = PySequence_ITEM(__pyx_t_6, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          __pyx_t_12 = __pyx_t_9(__pyx_t_6);
          if (unlikely(!__pyx_t_12)) {
            if (PyErr_Occurred()) {
              if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_12);
        }
        __Pyx_XDECREF(__pyx_v_oxygen);
        __pyx_v_oxygen = __pyx_t_12;
        __pyx_t_12 = 0;
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_XDECREF(__pyx_v_j);
        __pyx_v_j = __pyx_t_1;
        __pyx_t_12 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_1);
        __pyx_t_1 = __pyx_t_12;
        __pyx_t_12 = 0;
 1845:                     if i != j:
        /* "water_algorithm_cython.pyx":1845
 *                 axis_to_second_closest_oxygen = -1
 *                 for j, oxygen in enumerate(oxygens):
 *                     if i != j:             # <<<<<<<<<<<<<<
 *                         distance = np.linalg.norm(atoms[hydrogen_no].get_position()-oxygens.get_positions()[j])
 *                         if smallest_distance == None or distance < smallest_distance:
 */
        __pyx_t_12 = PyObject_RichCompare(__pyx_v_i, __pyx_v_j, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (__pyx_t_14) {
 1846:                         distance = np.linalg.norm(atoms[hydrogen_no].get_position()-oxygens.get_positions()[j])
          /* "water_algorithm_cython.pyx":1846
 *                 for j, oxygen in enumerate(oxygens):
 *                     if i != j:
 *                         distance = np.linalg.norm(atoms[hydrogen_no].get_position()-oxygens.get_positions()[j])             # <<<<<<<<<<<<<<
 *                         if smallest_distance == None or distance < smallest_distance:
 *                             axis_to_second_closest_oxygen = 13
 */
          __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__linalg); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s__norm); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = PyObject_GetItem(__pyx_v_atoms, __pyx_v_hydrogen_no); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s__get_position); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_10 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = PyObject_GetItem(__pyx_t_10, __pyx_v_j); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = PyNumber_Subtract(__pyx_t_11, __pyx_t_13); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_10 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_v_distance);
          __pyx_v_distance = __pyx_t_10;
          __pyx_t_10 = 0;
 1847:                         if smallest_distance == None or distance < smallest_distance:
          /* "water_algorithm_cython.pyx":1847
 *                     if i != j:
 *                         distance = np.linalg.norm(atoms[hydrogen_no].get_position()-oxygens.get_positions()[j])
 *                         if smallest_distance == None or distance < smallest_distance:             # <<<<<<<<<<<<<<
 *                             axis_to_second_closest_oxygen = 13
 *                             smallest_distance = distance
 */
          __pyx_t_10 = PyObject_RichCompare(__pyx_v_smallest_distance, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (!__pyx_t_14) {
            __pyx_t_10 = PyObject_RichCompare(__pyx_v_distance, __pyx_v_smallest_distance, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_7 = __pyx_t_15;
          } else {
            __pyx_t_7 = __pyx_t_14;
          }
          if (__pyx_t_7) {
 1848:                             axis_to_second_closest_oxygen = 13
            /* "water_algorithm_cython.pyx":1848
 *                         distance = np.linalg.norm(atoms[hydrogen_no].get_position()-oxygens.get_positions()[j])
 *                         if smallest_distance == None or distance < smallest_distance:
 *                             axis_to_second_closest_oxygen = 13             # <<<<<<<<<<<<<<
 *                             smallest_distance = distance
 *                             second_closest_oxygen = j
 */
            __Pyx_INCREF(__pyx_int_13);
            __Pyx_DECREF(__pyx_v_axis_to_second_closest_oxygen);
            __pyx_v_axis_to_second_closest_oxygen = __pyx_int_13;
 1849:                             smallest_distance = distance
            /* "water_algorithm_cython.pyx":1849
 *                         if smallest_distance == None or distance < smallest_distance:
 *                             axis_to_second_closest_oxygen = 13
 *                             smallest_distance = distance             # <<<<<<<<<<<<<<
 *                             second_closest_oxygen = j
 *                     if self.periodic:
 */
            __Pyx_INCREF(__pyx_v_distance);
            __Pyx_DECREF(__pyx_v_smallest_distance);
            __pyx_v_smallest_distance = __pyx_v_distance;
 1850:                             second_closest_oxygen = j
            /* "water_algorithm_cython.pyx":1850
 *                             axis_to_second_closest_oxygen = 13
 *                             smallest_distance = distance
 *                             second_closest_oxygen = j             # <<<<<<<<<<<<<<
 *                     if self.periodic:
 *                         assert self.cell != None
 */
            __Pyx_INCREF(__pyx_v_j);
            __Pyx_DECREF(__pyx_v_second_closest_oxygen);
            __pyx_v_second_closest_oxygen = __pyx_v_j;
            goto __pyx_L25;
          }
          __pyx_L25:;
          goto __pyx_L24;
        }
        __pyx_L24:;
 1851:                     if self.periodic:
        /* "water_algorithm_cython.pyx":1851
 *                             smallest_distance = distance
 *                             second_closest_oxygen = j
 *                     if self.periodic:             # <<<<<<<<<<<<<<
 *                         assert self.cell != None
 *                         periodic_distances, axis = get_periodic_distances(atoms[hydrogen_no].get_position(), oxygens.get_positions()[j], self.cell)
 */
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_7) {
 1852:                         assert self.cell != None
          /* "water_algorithm_cython.pyx":1852
 *                             second_closest_oxygen = j
 *                     if self.periodic:
 *                         assert self.cell != None             # <<<<<<<<<<<<<<
 *                         periodic_distances, axis = get_periodic_distances(atoms[hydrogen_no].get_position(), oxygens.get_positions()[j], self.cell)
 *                         for k, periodic_distance in enumerate(periodic_distances):
 */
          #ifndef CYTHON_WITHOUT_ASSERTIONS
          __pyx_t_10 = PyObject_RichCompare(__pyx_v_self->cell, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_7)) {
            PyErr_SetNone(PyExc_AssertionError);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #endif
 1853:                         periodic_distances, axis = get_periodic_distances(atoms[hydrogen_no].get_position(), oxygens.get_positions()[j], self.cell)
          /* "water_algorithm_cython.pyx":1853
 *                     if self.periodic:
 *                         assert self.cell != None
 *                         periodic_distances, axis = get_periodic_distances(atoms[hydrogen_no].get_position(), oxygens.get_positions()[j], self.cell)             # <<<<<<<<<<<<<<
 *                         for k, periodic_distance in enumerate(periodic_distances):
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 */
          __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_140); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_13 = PyObject_GetItem(__pyx_v_atoms, __pyx_v_hydrogen_no); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s__get_position); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_11 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = PyObject_GetItem(__pyx_t_11, __pyx_v_j); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_v_self->cell);
          PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_self->cell);
          __Pyx_GIVEREF(__pyx_v_self->cell);
          __pyx_t_13 = 0;
          __pyx_t_12 = 0;
          __pyx_t_12 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
          if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
            PyObject* sequence = __pyx_t_12;
            #if CYTHON_COMPILING_IN_CPYTHON
            Py_ssize_t size = Py_SIZE(sequence);
            #else
            Py_ssize_t size = PySequence_Size(sequence);
            #endif
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            #if CYTHON_COMPILING_IN_CPYTHON
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
              __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
            } else {
              __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
              __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
            }
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_10);
            #else
            __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_10);
            #endif
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } else
          {
            Py_ssize_t index = -1;
            __pyx_t_13 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_16 = Py_TYPE(__pyx_t_13)->tp_iternext;
            index = 0; __pyx_t_11 = __pyx_t_16(__pyx_t_13); if (unlikely(!__pyx_t_11)) goto __pyx_L27_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_11);
            index = 1; __pyx_t_10 = __pyx_t_16(__pyx_t_13); if (unlikely(!__pyx_t_10)) goto __pyx_L27_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_10);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_13), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_16 = NULL;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L28_unpacking_done;
            __pyx_L27_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_16 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_L28_unpacking_done:;
          }
          __Pyx_XDECREF(__pyx_v_periodic_distances);
          __pyx_v_periodic_distances = __pyx_t_11;
          __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_v_axis);
          __pyx_v_axis = __pyx_t_10;
          __pyx_t_10 = 0;
 1854:                         for k, periodic_distance in enumerate(periodic_distances):
          /* "water_algorithm_cython.pyx":1854
 *                         assert self.cell != None
 *                         periodic_distances, axis = get_periodic_distances(atoms[hydrogen_no].get_position(), oxygens.get_positions()[j], self.cell)
 *                         for k, periodic_distance in enumerate(periodic_distances):             # <<<<<<<<<<<<<<
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 *                                 axis_to_second_closest_oxygen = axis[k]
 */
          __Pyx_INCREF(__pyx_int_0);
          __pyx_t_12 = __pyx_int_0;
          if (PyList_CheckExact(__pyx_v_periodic_distances) || PyTuple_CheckExact(__pyx_v_periodic_distances)) {
            __pyx_t_10 = __pyx_v_periodic_distances; __Pyx_INCREF(__pyx_t_10); __pyx_t_22 = 0;
            __pyx_t_18 = NULL;
          } else {
            __pyx_t_22 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_v_periodic_distances); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_18 = Py_TYPE(__pyx_t_10)->tp_iternext;
          }
          for (;;) {
            if (!__pyx_t_18 && PyList_CheckExact(__pyx_t_10)) {
              if (__pyx_t_22 >= PyList_GET_SIZE(__pyx_t_10)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_11 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_22); __Pyx_INCREF(__pyx_t_11); __pyx_t_22++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_10, __pyx_t_22); __pyx_t_22++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #endif
            } else if (!__pyx_t_18 && PyTuple_CheckExact(__pyx_t_10)) {
              if (__pyx_t_22 >= PyTuple_GET_SIZE(__pyx_t_10)) break;
              #if CYTHON_COMPILING_IN_CPYTHON
              __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_22); __Pyx_INCREF(__pyx_t_11); __pyx_t_22++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #else
              __pyx_t_11 = PySequence_ITEM(__pyx_t_10, __pyx_t_22); __pyx_t_22++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              #endif
            } else {
              __pyx_t_11 = __pyx_t_18(__pyx_t_10);
              if (unlikely(!__pyx_t_11)) {
                if (PyErr_Occurred()) {
                  if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
                  else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                }
                break;
              }
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_XDECREF(__pyx_v_periodic_distance);
            __pyx_v_periodic_distance = __pyx_t_11;
            __pyx_t_11 = 0;
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_XDECREF(__pyx_v_k);
            __pyx_v_k = __pyx_t_12;
            __pyx_t_11 = PyNumber_Add(__pyx_t_12, __pyx_int_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_DECREF(__pyx_t_12);
            __pyx_t_12 = __pyx_t_11;
            __pyx_t_11 = 0;
 1855:                             if smallest_distance == None or periodic_distance < smallest_distance:
            /* "water_algorithm_cython.pyx":1855
 *                         periodic_distances, axis = get_periodic_distances(atoms[hydrogen_no].get_position(), oxygens.get_positions()[j], self.cell)
 *                         for k, periodic_distance in enumerate(periodic_distances):
 *                             if smallest_distance == None or periodic_distance < smallest_distance:             # <<<<<<<<<<<<<<
 *                                 axis_to_second_closest_oxygen = axis[k]
 *                                 smallest_distance = periodic_distance
 */
            __pyx_t_11 = PyObject_RichCompare(__pyx_v_smallest_distance, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (!__pyx_t_7) {
              __pyx_t_11 = PyObject_RichCompare(__pyx_v_periodic_distance, __pyx_v_smallest_distance, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __pyx_t_15 = __pyx_t_14;
            } else {
              __pyx_t_15 = __pyx_t_7;
            }
            if (__pyx_t_15) {
 1856:                                 axis_to_second_closest_oxygen = axis[k]
              /* "water_algorithm_cython.pyx":1856
 *                         for k, periodic_distance in enumerate(periodic_distances):
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 *                                 axis_to_second_closest_oxygen = axis[k]             # <<<<<<<<<<<<<<
 *                                 smallest_distance = periodic_distance
 *                                 second_closest_oxygen = j
 */
              __pyx_t_11 = PyObject_GetItem(__pyx_v_axis, __pyx_v_k); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_v_axis_to_second_closest_oxygen);
              __pyx_v_axis_to_second_closest_oxygen = __pyx_t_11;
              __pyx_t_11 = 0;
 1857:                                 smallest_distance = periodic_distance
              /* "water_algorithm_cython.pyx":1857
 *                             if smallest_distance == None or periodic_distance < smallest_distance:
 *                                 axis_to_second_closest_oxygen = axis[k]
 *                                 smallest_distance = periodic_distance             # <<<<<<<<<<<<<<
 *                                 second_closest_oxygen = j
 *                 if smallest_distance != None:
 */
              __Pyx_INCREF(__pyx_v_periodic_distance);
              __Pyx_DECREF(__pyx_v_smallest_distance);
              __pyx_v_smallest_distance = __pyx_v_periodic_distance;
 1858:                                 second_closest_oxygen = j
              /* "water_algorithm_cython.pyx":1858
 *                                 axis_to_second_closest_oxygen = axis[k]
 *                                 smallest_distance = periodic_distance
 *                                 second_closest_oxygen = j             # <<<<<<<<<<<<<<
 *                 if smallest_distance != None:
 *                     if smallest_distance < self.O_O_distance:
 */
              __Pyx_INCREF(__pyx_v_j);
              __Pyx_DECREF(__pyx_v_second_closest_oxygen);
              __pyx_v_second_closest_oxygen = __pyx_v_j;
              goto __pyx_L31;
            }
            __pyx_L31:;
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L26;
        }
        __pyx_L26:;
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 1859:                 if smallest_distance != None:
      /* "water_algorithm_cython.pyx":1859
 *                                 smallest_distance = periodic_distance
 *                                 second_closest_oxygen = j
 *                 if smallest_distance != None:             # <<<<<<<<<<<<<<
 *                     if smallest_distance < self.O_O_distance:
 *                         if smallest_distance > self.O_O_distance - 0.3:
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_smallest_distance, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_15) {
 1860:                     if smallest_distance < self.O_O_distance:
        /* "water_algorithm_cython.pyx":1860
 *                                 second_closest_oxygen = j
 *                 if smallest_distance != None:
 *                     if smallest_distance < self.O_O_distance:             # <<<<<<<<<<<<<<
 *                         if smallest_distance > self.O_O_distance - 0.3:
 *                             elongated_hydrogen_bonds = True
 */
        __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->O_O_distance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = PyObject_RichCompare(__pyx_v_smallest_distance, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_15) {
 1861:                         if smallest_distance > self.O_O_distance - 0.3:
          /* "water_algorithm_cython.pyx":1861
 *                 if smallest_distance != None:
 *                     if smallest_distance < self.O_O_distance:
 *                         if smallest_distance > self.O_O_distance - 0.3:             # <<<<<<<<<<<<<<
 *                             elongated_hydrogen_bonds = True
 *                         if second_closest_oxygen not in bond_variables:
 */
          __pyx_t_6 = PyFloat_FromDouble((__pyx_v_self->O_O_distance - 0.3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_1 = PyObject_RichCompare(__pyx_v_smallest_distance, __pyx_t_6, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_15) {
 1862:                             elongated_hydrogen_bonds = True
            /* "water_algorithm_cython.pyx":1862
 *                     if smallest_distance < self.O_O_distance:
 *                         if smallest_distance > self.O_O_distance - 0.3:
 *                             elongated_hydrogen_bonds = True             # <<<<<<<<<<<<<<
 *                         if second_closest_oxygen not in bond_variables:
 *                             bond_variables[second_closest_oxygen] = {}
 */
            __pyx_v_elongated_hydrogen_bonds = 1;
            goto __pyx_L34;
          }
          __pyx_L34:;
 1863:                         if second_closest_oxygen not in bond_variables:
          /* "water_algorithm_cython.pyx":1863
 *                         if smallest_distance > self.O_O_distance - 0.3:
 *                             elongated_hydrogen_bonds = True
 *                         if second_closest_oxygen not in bond_variables:             # <<<<<<<<<<<<<<
 *                             bond_variables[second_closest_oxygen] = {}
 *                         if i not in bond_variables[second_closest_oxygen]:
 */
          __pyx_t_15 = (__Pyx_PyDict_Contains(__pyx_v_second_closest_oxygen, ((PyObject *)__pyx_v_bond_variables), Py_NE)); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          if (__pyx_t_15) {
 1864:                             bond_variables[second_closest_oxygen] = {}
            /* "water_algorithm_cython.pyx":1864
 *                             elongated_hydrogen_bonds = True
 *                         if second_closest_oxygen not in bond_variables:
 *                             bond_variables[second_closest_oxygen] = {}             # <<<<<<<<<<<<<<
 *                         if i not in bond_variables[second_closest_oxygen]:
 *                             bond_variables[second_closest_oxygen][i] = {}
 */
            __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_1));
            if (PyDict_SetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_second_closest_oxygen, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
            goto __pyx_L35;
          }
          __pyx_L35:;
 1865:                         if i not in bond_variables[second_closest_oxygen]:
          /* "water_algorithm_cython.pyx":1865
 *                         if second_closest_oxygen not in bond_variables:
 *                             bond_variables[second_closest_oxygen] = {}
 *                         if i not in bond_variables[second_closest_oxygen]:             # <<<<<<<<<<<<<<
 *                             bond_variables[second_closest_oxygen][i] = {}
 *                         if second_closest_oxygen not in bond_variables[i]:
 */
          __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_second_closest_oxygen); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_15 = (__Pyx_PySequence_Contains(__pyx_v_i, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_15) {
 1866:                             bond_variables[second_closest_oxygen][i] = {}
            /* "water_algorithm_cython.pyx":1866
 *                             bond_variables[second_closest_oxygen] = {}
 *                         if i not in bond_variables[second_closest_oxygen]:
 *                             bond_variables[second_closest_oxygen][i] = {}             # <<<<<<<<<<<<<<
 *                         if second_closest_oxygen not in bond_variables[i]:
 *                             bond_variables[i][second_closest_oxygen] = {}
 */
            __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_1));
            __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_second_closest_oxygen); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            if (PyObject_SetItem(__pyx_t_6, __pyx_v_i, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
            goto __pyx_L36;
          }
          __pyx_L36:;
 1867:                         if second_closest_oxygen not in bond_variables[i]:
          /* "water_algorithm_cython.pyx":1867
 *                         if i not in bond_variables[second_closest_oxygen]:
 *                             bond_variables[second_closest_oxygen][i] = {}
 *                         if second_closest_oxygen not in bond_variables[i]:             # <<<<<<<<<<<<<<
 *                             bond_variables[i][second_closest_oxygen] = {}
 *                         opposite_periodicity_axis = get_opposite_periodicity_axis_number(axis_to_second_closest_oxygen)
 */
          __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_15 = (__Pyx_PySequence_Contains(__pyx_v_second_closest_oxygen, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_15) {
 1868:                             bond_variables[i][second_closest_oxygen] = {}
            /* "water_algorithm_cython.pyx":1868
 *                             bond_variables[second_closest_oxygen][i] = {}
 *                         if second_closest_oxygen not in bond_variables[i]:
 *                             bond_variables[i][second_closest_oxygen] = {}             # <<<<<<<<<<<<<<
 *                         opposite_periodicity_axis = get_opposite_periodicity_axis_number(axis_to_second_closest_oxygen)
 *                         bond_variables[i][second_closest_oxygen][axis_to_second_closest_oxygen] = 1
 */
            __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_1));
            __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            if (PyObject_SetItem(__pyx_t_6, __pyx_v_second_closest_oxygen, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
            goto __pyx_L37;
          }
          __pyx_L37:;
 1869:                         opposite_periodicity_axis = get_opposite_periodicity_axis_number(axis_to_second_closest_oxygen)
          /* "water_algorithm_cython.pyx":1869
 *                         if second_closest_oxygen not in bond_variables[i]:
 *                             bond_variables[i][second_closest_oxygen] = {}
 *                         opposite_periodicity_axis = get_opposite_periodicity_axis_number(axis_to_second_closest_oxygen)             # <<<<<<<<<<<<<<
 *                         bond_variables[i][second_closest_oxygen][axis_to_second_closest_oxygen] = 1
 *                         bond_variables[second_closest_oxygen][i][opposite_periodicity_axis] = -1
 */
          __pyx_t_23 = __Pyx_PyInt_from_py_npy_uint8(__pyx_v_axis_to_second_closest_oxygen); if (unlikely((__pyx_t_23 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_v_opposite_periodicity_axis = __pyx_f_22water_algorithm_cython_get_opposite_periodicity_axis_number(__pyx_t_23);
 1870:                         bond_variables[i][second_closest_oxygen][axis_to_second_closest_oxygen] = 1
          /* "water_algorithm_cython.pyx":1870
 *                             bond_variables[i][second_closest_oxygen] = {}
 *                         opposite_periodicity_axis = get_opposite_periodicity_axis_number(axis_to_second_closest_oxygen)
 *                         bond_variables[i][second_closest_oxygen][axis_to_second_closest_oxygen] = 1             # <<<<<<<<<<<<<<
 *                         bond_variables[second_closest_oxygen][i][opposite_periodicity_axis] = -1
 *                     else:  # No second closest oxygen found -> dangling hydrogen bond
 */
          __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_v_second_closest_oxygen); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (PyObject_SetItem(__pyx_t_6, __pyx_v_axis_to_second_closest_oxygen, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 1871:                         bond_variables[second_closest_oxygen][i][opposite_periodicity_axis] = -1
          /* "water_algorithm_cython.pyx":1871
 *                         opposite_periodicity_axis = get_opposite_periodicity_axis_number(axis_to_second_closest_oxygen)
 *                         bond_variables[i][second_closest_oxygen][axis_to_second_closest_oxygen] = 1
 *                         bond_variables[second_closest_oxygen][i][opposite_periodicity_axis] = -1             # <<<<<<<<<<<<<<
 *                     else:  # No second closest oxygen found -> dangling hydrogen bond
 *                         if i not in bond_variables[i]:
 */
          __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_second_closest_oxygen); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_1 = PyObject_GetItem(__pyx_t_6, __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (__Pyx_SetItemInt(__pyx_t_1, __pyx_v_opposite_periodicity_axis, __pyx_int_neg_1, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L33;
        }
        /*else*/ {
 1872:                     else:  # No second closest oxygen found -> dangling hydrogen bond
 1873:                         if i not in bond_variables[i]:
          /* "water_algorithm_cython.pyx":1873
 *                         bond_variables[second_closest_oxygen][i][opposite_periodicity_axis] = -1
 *                     else:  # No second closest oxygen found -> dangling hydrogen bond
 *                         if i not in bond_variables[i]:             # <<<<<<<<<<<<<<
 *                             bond_variables[i][i] = {}
 *                         bond_variables[i][i][13] = 1
 */
          __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_15 = (__Pyx_PySequence_Contains(__pyx_v_i, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_15 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_15) {
 1874:                             bond_variables[i][i] = {}
            /* "water_algorithm_cython.pyx":1874
 *                     else:  # No second closest oxygen found -> dangling hydrogen bond
 *                         if i not in bond_variables[i]:
 *                             bond_variables[i][i] = {}             # <<<<<<<<<<<<<<
 *                         bond_variables[i][i][13] = 1
 * 
 */
            __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_1));
            __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_6);
            if (PyObject_SetItem(__pyx_t_6, __pyx_v_i, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
            goto __pyx_L38;
          }
          __pyx_L38:;
 1875:                         bond_variables[i][i][13] = 1
          /* "water_algorithm_cython.pyx":1875
 *                         if i not in bond_variables[i]:
 *                             bond_variables[i][i] = {}
 *                         bond_variables[i][i][13] = 1             # <<<<<<<<<<<<<<
 * 
 *         # NOTE: does not include dangling oxygen bonds
 */
          __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__Pyx_SetItemInt(__pyx_t_6, 13, __pyx_int_1, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __pyx_L33:;
        goto __pyx_L32;
      }
      __pyx_L32:;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1876: 
 1877:         # NOTE: does not include dangling oxygen bonds
 1878:         return bond_variables, elongated_bonds, elongated_hydrogen_bonds
  /* "water_algorithm_cython.pyx":1878
 * 
 *         # NOTE: does not include dangling oxygen bonds
 *         return bond_variables, elongated_bonds, elongated_hydrogen_bonds             # <<<<<<<<<<<<<<
 * 
 *     def get_water_orientations_from_bond_variables_and_molecule_change_matrix(self, bond_variables, equals = None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_elongated_bonds); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_elongated_hydrogen_bonds); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_bond_variables));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_bond_variables));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_bond_variables));
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_bond_varibles_from_atoms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XDECREF(__pyx_v_nearest_hydrogens);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_atom);
  __Pyx_XDECREF(__pyx_v_smallest_distance);
  __Pyx_XDECREF(__pyx_v_smallest_distance_oxygen);
  __Pyx_XDECREF(__pyx_v_axis_to_closest_oxygen);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_oxygen);
  __Pyx_XDECREF(__pyx_v_distance);
  __Pyx_XDECREF(__pyx_v_periodic_distances);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_periodic_distance);
  __Pyx_XDECREF(__pyx_v_bond_variables);
  __Pyx_XDECREF(__pyx_v_nearest_hydrogens_o);
  __Pyx_XDECREF(__pyx_v_hydrogen_no);
  __Pyx_XDECREF(__pyx_v_second_closest_oxygen);
  __Pyx_XDECREF(__pyx_v_axis_to_second_closest_oxygen);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_73get_water_orientations_from_bond_variables_and_molecule_change_matrix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_73get_water_orientations_from_bond_variables_and_molecule_change_matrix(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bond_variables = 0;
  PyObject *__pyx_v_equals = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_water_orientations_from_bond_variables_and_molecule_change_matrix (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bond_variables,&__pyx_n_s__equals,0};
    PyObject* values[2] = {0,0};
 1879: 
 1880:     def get_water_orientations_from_bond_variables_and_molecule_change_matrix(self, bond_variables, equals = None):
    /* "water_algorithm_cython.pyx":1880
 *         return bond_variables, elongated_bonds, elongated_hydrogen_bonds
 * 
 *     def get_water_orientations_from_bond_variables_and_molecule_change_matrix(self, bond_variables, equals = None):             # <<<<<<<<<<<<<<
 *         if equals == None:
 *             equals = np.arange(0, self.N, dtype='int')
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bond_variables)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__equals);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_water_orientations_from_bond_variables_and_molecule_change_matrix") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bond_variables = values[0];
    __pyx_v_equals = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_water_orientations_from_bond_variables_and_molecule_change_matrix", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1880; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_water_orientations_from_bond_variables_and_molecule_change_matrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_72get_water_orientations_from_bond_variables_and_molecule_change_matrix(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_bond_variables, __pyx_v_equals);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_72get_water_orientations_from_bond_variables_and_molecule_change_matrix(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_bond_variables, PyObject *__pyx_v_equals) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_new_molecule_no = NULL;
  PyObject *__pyx_v_bvv = NULL;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_nn = NULL;
  PyObject *__pyx_v_new_neighbor_no = NULL;
  PyObject *__pyx_v_axis = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_water_orientations_from_bond_variables_and_molecule_change_matrix", 0);
  __Pyx_INCREF(__pyx_v_equals);
 1881:         if equals == None:
  /* "water_algorithm_cython.pyx":1881
 * 
 *     def get_water_orientations_from_bond_variables_and_molecule_change_matrix(self, bond_variables, equals = None):
 *         if equals == None:             # <<<<<<<<<<<<<<
 *             equals = np.arange(0, self.N, dtype='int')
 *         result = []
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_equals, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {
 1882:             equals = np.arange(0, self.N, dtype='int')
    /* "water_algorithm_cython.pyx":1882
 *     def get_water_orientations_from_bond_variables_and_molecule_change_matrix(self, bond_variables, equals = None):
 *         if equals == None:
 *             equals = np.arange(0, self.N, dtype='int')             # <<<<<<<<<<<<<<
 *         result = []
 *         for i, new_molecule_no in enumerate(equals):
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__arange); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_v_equals);
    __pyx_v_equals = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 1883:         result = []
  /* "water_algorithm_cython.pyx":1883
 *         if equals == None:
 *             equals = np.arange(0, self.N, dtype='int')
 *         result = []             # <<<<<<<<<<<<<<
 *         for i, new_molecule_no in enumerate(equals):
 *             bvv = [-1, -1, -1, -1]
 */
  __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_v_result = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
 1884:         for i, new_molecule_no in enumerate(equals):
  /* "water_algorithm_cython.pyx":1884
 *             equals = np.arange(0, self.N, dtype='int')
 *         result = []
 *         for i, new_molecule_no in enumerate(equals):             # <<<<<<<<<<<<<<
 *             bvv = [-1, -1, -1, -1]
 *             for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_5 = __pyx_int_0;
  if (PyList_CheckExact(__pyx_v_equals) || PyTuple_CheckExact(__pyx_v_equals)) {
    __pyx_t_1 = __pyx_v_equals; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_equals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_4 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF(__pyx_v_new_molecule_no);
    __pyx_v_new_molecule_no = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_5;
    __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5);
    __pyx_t_5 = __pyx_t_4;
    __pyx_t_4 = 0;
 1885:             bvv = [-1, -1, -1, -1]
    /* "water_algorithm_cython.pyx":1885
 *         result = []
 *         for i, new_molecule_no in enumerate(equals):
 *             bvv = [-1, -1, -1, -1]             # <<<<<<<<<<<<<<
 *             for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *                 new_neighbor_no = equals[nn]
 */
    __pyx_t_4 = PyList_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_int_neg_1);
    PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    __Pyx_INCREF(__pyx_int_neg_1);
    PyList_SET_ITEM(__pyx_t_4, 1, __pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    __Pyx_INCREF(__pyx_int_neg_1);
    PyList_SET_ITEM(__pyx_t_4, 2, __pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    __Pyx_INCREF(__pyx_int_neg_1);
    PyList_SET_ITEM(__pyx_t_4, 3, __pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    __Pyx_XDECREF(((PyObject *)__pyx_v_bvv));
    __pyx_v_bvv = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 1886:             for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
    /* "water_algorithm_cython.pyx":1886
 *         for i, new_molecule_no in enumerate(equals):
 *             bvv = [-1, -1, -1, -1]
 *             for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):             # <<<<<<<<<<<<<<
 *                 new_neighbor_no = equals[nn]
 *                 axis = self.nearest_neighbors_nos[2][i][j]
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_4 = __pyx_int_0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetItem(__pyx_t_8, __pyx_v_i); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_8 = __pyx_t_3; __Pyx_INCREF(__pyx_t_8); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_9 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_8)) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_8)) {
        if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_3 = __pyx_t_10(__pyx_t_8);
        if (unlikely(!__pyx_t_3)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF(__pyx_v_nn);
      __pyx_v_nn = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_v_j);
      __pyx_v_j = __pyx_t_4;
      __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = __pyx_t_3;
      __pyx_t_3 = 0;
 1887:                 new_neighbor_no = equals[nn]
      /* "water_algorithm_cython.pyx":1887
 *             bvv = [-1, -1, -1, -1]
 *             for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *                 new_neighbor_no = equals[nn]             # <<<<<<<<<<<<<<
 *                 axis = self.nearest_neighbors_nos[2][i][j]
 *                 if new_neighbor_no == new_molecule_no and axis == 13:
 */
      __pyx_t_3 = PyObject_GetItem(__pyx_v_equals, __pyx_v_nn); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_v_new_neighbor_no);
      __pyx_v_new_neighbor_no = __pyx_t_3;
      __pyx_t_3 = 0;
 1888:                 axis = self.nearest_neighbors_nos[2][i][j]
      /* "water_algorithm_cython.pyx":1888
 *             for j, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *                 new_neighbor_no = equals[nn]
 *                 axis = self.nearest_neighbors_nos[2][i][j]             # <<<<<<<<<<<<<<
 *                 if new_neighbor_no == new_molecule_no and axis == 13:
 *                     # TAKE care of the missing dangling oxygen bonds
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_t_3, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(__pyx_t_11, __pyx_v_i); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_v_axis);
      __pyx_v_axis = __pyx_t_11;
      __pyx_t_11 = 0;
 1889:                 if new_neighbor_no == new_molecule_no and axis == 13:
      /* "water_algorithm_cython.pyx":1889
 *                 new_neighbor_no = equals[nn]
 *                 axis = self.nearest_neighbors_nos[2][i][j]
 *                 if new_neighbor_no == new_molecule_no and axis == 13:             # <<<<<<<<<<<<<<
 *                     # TAKE care of the missing dangling oxygen bonds
 *                     if new_neighbor_no not in bond_variables[new_molecule_no] or axis not in bond_variables[new_molecule_no][new_neighbor_no]:
 */
      __pyx_t_11 = PyObject_RichCompare(__pyx_v_new_neighbor_no, __pyx_v_new_molecule_no, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (__pyx_t_2) {
        __pyx_t_11 = PyObject_RichCompare(__pyx_v_axis, __pyx_int_13, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_13 = __pyx_t_12;
      } else {
        __pyx_t_13 = __pyx_t_2;
      }
      if (__pyx_t_13) {
 1890:                     # TAKE care of the missing dangling oxygen bonds
 1891:                     if new_neighbor_no not in bond_variables[new_molecule_no] or axis not in bond_variables[new_molecule_no][new_neighbor_no]:
        /* "water_algorithm_cython.pyx":1891
 *                 if new_neighbor_no == new_molecule_no and axis == 13:
 *                     # TAKE care of the missing dangling oxygen bonds
 *                     if new_neighbor_no not in bond_variables[new_molecule_no] or axis not in bond_variables[new_molecule_no][new_neighbor_no]:             # <<<<<<<<<<<<<<
 *                         bvv[j] = -1
 *                     else:
 */
        __pyx_t_11 = PyObject_GetItem(__pyx_v_bond_variables, __pyx_v_new_molecule_no); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_13 = (__Pyx_PySequence_Contains(__pyx_v_new_neighbor_no, __pyx_t_11, Py_NE)); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (!__pyx_t_13) {
          __pyx_t_11 = PyObject_GetItem(__pyx_v_bond_variables, __pyx_v_new_molecule_no); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_3 = PyObject_GetItem(__pyx_t_11, __pyx_v_new_neighbor_no); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_2 = (__Pyx_PySequence_Contains(__pyx_v_axis, __pyx_t_3, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_12 = __pyx_t_2;
        } else {
          __pyx_t_12 = __pyx_t_13;
        }
        if (__pyx_t_12) {
 1892:                         bvv[j] = -1
          /* "water_algorithm_cython.pyx":1892
 *                     # TAKE care of the missing dangling oxygen bonds
 *                     if new_neighbor_no not in bond_variables[new_molecule_no] or axis not in bond_variables[new_molecule_no][new_neighbor_no]:
 *                         bvv[j] = -1             # <<<<<<<<<<<<<<
 *                     else:
 *                         bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
 */
          if (PyObject_SetItem(((PyObject *)__pyx_v_bvv), __pyx_v_j, __pyx_int_neg_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          goto __pyx_L9;
        }
        /*else*/ {
 1893:                     else:
 1894:                         bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
          /* "water_algorithm_cython.pyx":1894
 *                         bvv[j] = -1
 *                     else:
 *                         bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]             # <<<<<<<<<<<<<<
 *                         assert bvv[j] == 1
 *                 else:
 */
          __pyx_t_3 = PyObject_GetItem(__pyx_v_bond_variables, __pyx_v_new_molecule_no); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_11 = PyObject_GetItem(__pyx_t_3, __pyx_v_new_neighbor_no); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyObject_GetItem(__pyx_t_11, __pyx_v_axis); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (PyObject_SetItem(((PyObject *)__pyx_v_bvv), __pyx_v_j, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 1895:                         assert bvv[j] == 1
          /* "water_algorithm_cython.pyx":1895
 *                     else:
 *                         bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
 *                         assert bvv[j] == 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
 */
          #ifndef CYTHON_WITHOUT_ASSERTIONS
          __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_bvv), __pyx_v_j); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_11 = PyObject_RichCompare(__pyx_t_3, __pyx_int_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_12)) {
            PyErr_SetNone(PyExc_AssertionError);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #endif
        }
        __pyx_L9:;
        goto __pyx_L8;
      }
      /*else*/ {
 1896:                 else:
 1897:                     bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
        /* "water_algorithm_cython.pyx":1897
 *                         assert bvv[j] == 1
 *                 else:
 *                     bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]             # <<<<<<<<<<<<<<
 *             result.append(get_water_orientation_from_bond_variable_values(bvv))
 *         return result
 */
        __pyx_t_11 = PyObject_GetItem(__pyx_v_bond_variables, __pyx_v_new_molecule_no); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_3 = PyObject_GetItem(__pyx_t_11, __pyx_v_new_neighbor_no); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_GetItem(__pyx_t_3, __pyx_v_axis); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (PyObject_SetItem(((PyObject *)__pyx_v_bvv), __pyx_v_j, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
      __pyx_L8:;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1898:             result.append(get_water_orientation_from_bond_variable_values(bvv))
    /* "water_algorithm_cython.pyx":1898
 *                 else:
 *                     bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
 *             result.append(get_water_orientation_from_bond_variable_values(bvv))             # <<<<<<<<<<<<<<
 *         return result
 * 
 */
    __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_bvv));
    if (unlikely(!__pyx_t_14.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyInt_to_py_npy_uint8(__pyx_f_22water_algorithm_cython_get_water_orientation_from_bond_variable_values(__pyx_t_14)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
    __pyx_t_15 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 1899:         return result
  /* "water_algorithm_cython.pyx":1899
 *                     bvv[j] = bond_variables[new_molecule_no][new_neighbor_no][axis]
 *             result.append(get_water_orientation_from_bond_variable_values(bvv))
 *         return result             # <<<<<<<<<<<<<<
 * 
 *     def print_nearest_neighbors_nos(self, bond_variables = None, symmetry_operation = None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_water_orientations_from_bond_variables_and_molecule_change_matrix", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_new_molecule_no);
  __Pyx_XDECREF(__pyx_v_bvv);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_nn);
  __Pyx_XDECREF(__pyx_v_new_neighbor_no);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF(__pyx_v_equals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_75print_nearest_neighbors_nos(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_75print_nearest_neighbors_nos(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bond_variables = 0;
  PyObject *__pyx_v_symmetry_operation = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_nearest_neighbors_nos (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__bond_variables,&__pyx_n_s__symmetry_operation,0};
    PyObject* values[2] = {0,0};
 1900: 
 1901:     def print_nearest_neighbors_nos(self, bond_variables = None, symmetry_operation = None):
    /* "water_algorithm_cython.pyx":1901
 *         return result
 * 
 *     def print_nearest_neighbors_nos(self, bond_variables = None, symmetry_operation = None):             # <<<<<<<<<<<<<<
 *         result = ""
 *         for i in range(self.N):
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bond_variables);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__symmetry_operation);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "print_nearest_neighbors_nos") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bond_variables = values[0];
    __pyx_v_symmetry_operation = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("print_nearest_neighbors_nos", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1901; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.print_nearest_neighbors_nos", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_74print_nearest_neighbors_nos(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_bond_variables, __pyx_v_symmetry_operation);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_74print_nearest_neighbors_nos(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_bond_variables, PyObject *__pyx_v_symmetry_operation) {
  PyObject *__pyx_v_result = NULL;
  unsigned char __pyx_v_i;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_new_no = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_nearest_neighbors_nos", 0);
 1902:         result = ""
  /* "water_algorithm_cython.pyx":1902
 * 
 *     def print_nearest_neighbors_nos(self, bond_variables = None, symmetry_operation = None):
 *         result = ""             # <<<<<<<<<<<<<<
 *         for i in range(self.N):
 *             result += "(%i): " % i
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  __pyx_v_result = __pyx_kp_s_1;
 1903:         for i in range(self.N):
  /* "water_algorithm_cython.pyx":1903
 *     def print_nearest_neighbors_nos(self, bond_variables = None, symmetry_operation = None):
 *         result = ""
 *         for i in range(self.N):             # <<<<<<<<<<<<<<
 *             result += "(%i): " % i
 *             if i < 10:
 */
  __pyx_t_1 = __pyx_v_self->N;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
 1904:             result += "(%i): " % i
    /* "water_algorithm_cython.pyx":1904
 *         result = ""
 *         for i in range(self.N):
 *             result += "(%i): " % i             # <<<<<<<<<<<<<<
 *             if i < 10:
 *                 result += " "
 */
    __pyx_t_3 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_141), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_result));
    __pyx_v_result = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
 1905:             if i < 10:
    /* "water_algorithm_cython.pyx":1905
 *         for i in range(self.N):
 *             result += "(%i): " % i
 *             if i < 10:             # <<<<<<<<<<<<<<
 *                 result += " "
 *             for j in range(len(self.nearest_neighbors_nos[0][i])):
 */
    __pyx_t_5 = (__pyx_v_i < 10);
    if (__pyx_t_5) {
 1906:                 result += " "
      /* "water_algorithm_cython.pyx":1906
 *             result += "(%i): " % i
 *             if i < 10:
 *                 result += " "             # <<<<<<<<<<<<<<
 *             for j in range(len(self.nearest_neighbors_nos[0][i])):
 *                 result += "%i" % self.nearest_neighbors_nos[0][i][j]
 */
      __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_142)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_DECREF(((PyObject *)__pyx_v_result));
      __pyx_v_result = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
 1907:             for j in range(len(self.nearest_neighbors_nos[0][i])):
    /* "water_algorithm_cython.pyx":1907
 *             if i < 10:
 *                 result += " "
 *             for j in range(len(self.nearest_neighbors_nos[0][i])):             # <<<<<<<<<<<<<<
 *                 result += "%i" % self.nearest_neighbors_nos[0][i][j]
 *                 if self.nearest_neighbors_nos[2][i][j] != 13:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_3 = __pyx_t_7(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF(__pyx_v_j);
      __pyx_v_j = __pyx_t_3;
      __pyx_t_3 = 0;
 1908:                 result += "%i" % self.nearest_neighbors_nos[0][i][j]
      /* "water_algorithm_cython.pyx":1908
 *                 result += " "
 *             for j in range(len(self.nearest_neighbors_nos[0][i])):
 *                 result += "%i" % self.nearest_neighbors_nos[0][i][j]             # <<<<<<<<<<<<<<
 *                 if self.nearest_neighbors_nos[2][i][j] != 13:
 *                     result += "_%i" % self.nearest_neighbors_nos[2][i][j]
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_143), __pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_result));
      __pyx_v_result = ((PyObject*)__pyx_t_8);
      __pyx_t_8 = 0;
 1909:                 if self.nearest_neighbors_nos[2][i][j] != 13:
      /* "water_algorithm_cython.pyx":1909
 *             for j in range(len(self.nearest_neighbors_nos[0][i])):
 *                 result += "%i" % self.nearest_neighbors_nos[0][i][j]
 *                 if self.nearest_neighbors_nos[2][i][j] != 13:             # <<<<<<<<<<<<<<
 *                     result += "_%i" % self.nearest_neighbors_nos[2][i][j]
 *                     if bond_variables != None:
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(__pyx_t_8, __pyx_v_j); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_int_13, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__pyx_t_5) {
 1910:                     result += "_%i" % self.nearest_neighbors_nos[2][i][j]
        /* "water_algorithm_cython.pyx":1910
 *                 result += "%i" % self.nearest_neighbors_nos[0][i][j]
 *                 if self.nearest_neighbors_nos[2][i][j] != 13:
 *                     result += "_%i" % self.nearest_neighbors_nos[2][i][j]             # <<<<<<<<<<<<<<
 *                     if bond_variables != None:
 *                         result +=": "
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_GetItem(__pyx_t_8, __pyx_v_j); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_144), __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_result));
        __pyx_v_result = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
 1911:                     if bond_variables != None:
        /* "water_algorithm_cython.pyx":1911
 *                 if self.nearest_neighbors_nos[2][i][j] != 13:
 *                     result += "_%i" % self.nearest_neighbors_nos[2][i][j]
 *                     if bond_variables != None:             # <<<<<<<<<<<<<<
 *                         result +=": "
 *                     if self.nearest_neighbors_nos[2][i][j] < 10:
 */
        __pyx_t_3 = PyObject_RichCompare(__pyx_v_bond_variables, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_5) {
 1912:                         result +=": "
          /* "water_algorithm_cython.pyx":1912
 *                     result += "_%i" % self.nearest_neighbors_nos[2][i][j]
 *                     if bond_variables != None:
 *                         result +=": "             # <<<<<<<<<<<<<<
 *                     if self.nearest_neighbors_nos[2][i][j] < 10:
 *                         result += " "
 */
          __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_145)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_3);
          __pyx_t_3 = 0;
          goto __pyx_L9;
        }
        __pyx_L9:;
 1913:                     if self.nearest_neighbors_nos[2][i][j] < 10:
        /* "water_algorithm_cython.pyx":1913
 *                     if bond_variables != None:
 *                         result +=": "
 *                     if self.nearest_neighbors_nos[2][i][j] < 10:             # <<<<<<<<<<<<<<
 *                         result += " "
 *                 else:
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_int_10, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_5) {
 1914:                         result += " "
          /* "water_algorithm_cython.pyx":1914
 *                         result +=": "
 *                     if self.nearest_neighbors_nos[2][i][j] < 10:
 *                         result += " "             # <<<<<<<<<<<<<<
 *                 else:
 *                     if bond_variables != None or symmetry_operation is not None:
 */
          __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_142)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_3);
          __pyx_t_3 = 0;
          goto __pyx_L10;
        }
        __pyx_L10:;
        goto __pyx_L8;
      }
      /*else*/ {
 1915:                 else:
 1916:                     if bond_variables != None or symmetry_operation is not None:
        /* "water_algorithm_cython.pyx":1916
 *                         result += " "
 *                 else:
 *                     if bond_variables != None or symmetry_operation is not None:             # <<<<<<<<<<<<<<
 *                         result +=":"
 *                     result += "    "
 */
        __pyx_t_3 = PyObject_RichCompare(__pyx_v_bond_variables, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (!__pyx_t_5) {
          __pyx_t_9 = (__pyx_v_symmetry_operation != Py_None);
          __pyx_t_10 = __pyx_t_9;
        } else {
          __pyx_t_10 = __pyx_t_5;
        }
        if (__pyx_t_10) {
 1917:                         result +=":"
          /* "water_algorithm_cython.pyx":1917
 *                 else:
 *                     if bond_variables != None or symmetry_operation is not None:
 *                         result +=":"             # <<<<<<<<<<<<<<
 *                     result += "    "
 *                 if self.nearest_neighbors_nos[0][i][j] < 10:
 */
          __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_146)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_3);
          __pyx_t_3 = 0;
          goto __pyx_L11;
        }
        __pyx_L11:;
 1918:                     result += "    "
        /* "water_algorithm_cython.pyx":1918
 *                     if bond_variables != None or symmetry_operation is not None:
 *                         result +=":"
 *                     result += "    "             # <<<<<<<<<<<<<<
 *                 if self.nearest_neighbors_nos[0][i][j] < 10:
 *                     result += " "
 */
        __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_88)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_DECREF(((PyObject *)__pyx_v_result));
        __pyx_v_result = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
      }
      __pyx_L8:;
 1919:                 if self.nearest_neighbors_nos[0][i][j] < 10:
      /* "water_algorithm_cython.pyx":1919
 *                         result +=":"
 *                     result += "    "
 *                 if self.nearest_neighbors_nos[0][i][j] < 10:             # <<<<<<<<<<<<<<
 *                     result += " "
 *                 if bond_variables != None:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_int_10, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_10) {
 1920:                     result += " "
        /* "water_algorithm_cython.pyx":1920
 *                     result += "    "
 *                 if self.nearest_neighbors_nos[0][i][j] < 10:
 *                     result += " "             # <<<<<<<<<<<<<<
 *                 if bond_variables != None:
 *                     if bond_variables[i][j] < 0:
 */
        __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_142)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_DECREF(((PyObject *)__pyx_v_result));
        __pyx_v_result = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
        goto __pyx_L12;
      }
      __pyx_L12:;
 1921:                 if bond_variables != None:
      /* "water_algorithm_cython.pyx":1921
 *                 if self.nearest_neighbors_nos[0][i][j] < 10:
 *                     result += " "
 *                 if bond_variables != None:             # <<<<<<<<<<<<<<
 *                     if bond_variables[i][j] < 0:
 *                         result += "%i  " % bond_variables[i][j]
 */
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_bond_variables, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_10) {
 1922:                     if bond_variables[i][j] < 0:
        /* "water_algorithm_cython.pyx":1922
 *                     result += " "
 *                 if bond_variables != None:
 *                     if bond_variables[i][j] < 0:             # <<<<<<<<<<<<<<
 *                         result += "%i  " % bond_variables[i][j]
 *                     else:
 */
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_bond_variables, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_10) {
 1923:                         result += "%i  " % bond_variables[i][j]
          /* "water_algorithm_cython.pyx":1923
 *                 if bond_variables != None:
 *                     if bond_variables[i][j] < 0:
 *                         result += "%i  " % bond_variables[i][j]             # <<<<<<<<<<<<<<
 *                     else:
 *                         result += " %i  " % bond_variables[i][j]
 */
          __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_bond_variables, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_147), __pyx_t_8); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_8);
          __pyx_t_8 = 0;
          goto __pyx_L14;
        }
        /*else*/ {
 1924:                     else:
 1925:                         result += " %i  " % bond_variables[i][j]
          /* "water_algorithm_cython.pyx":1925
 *                         result += "%i  " % bond_variables[i][j]
 *                     else:
 *                         result += " %i  " % bond_variables[i][j]             # <<<<<<<<<<<<<<
 *                 if symmetry_operation is not None:
 *                     new_no = symmetry_operation.molecule_change_matrix[i]
 */
          __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_bond_variables, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_3 = PyObject_GetItem(__pyx_t_8, __pyx_v_j); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_148), __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_3);
          __pyx_t_3 = 0;
        }
        __pyx_L14:;
        goto __pyx_L13;
      }
      __pyx_L13:;
 1926:                 if symmetry_operation is not None:
      /* "water_algorithm_cython.pyx":1926
 *                     else:
 *                         result += " %i  " % bond_variables[i][j]
 *                 if symmetry_operation is not None:             # <<<<<<<<<<<<<<
 *                     new_no = symmetry_operation.molecule_change_matrix[i]
 *                     k = symmetry_operation.nn_change_matrix[i][j]
 */
      __pyx_t_10 = (__pyx_v_symmetry_operation != Py_None);
      if (__pyx_t_10) {
 1927:                     new_no = symmetry_operation.molecule_change_matrix[i]
        /* "water_algorithm_cython.pyx":1927
 *                         result += " %i  " % bond_variables[i][j]
 *                 if symmetry_operation is not None:
 *                     new_no = symmetry_operation.molecule_change_matrix[i]             # <<<<<<<<<<<<<<
 *                     k = symmetry_operation.nn_change_matrix[i][j]
 *                     result += " %i-%i" % (new_no, self.nearest_neighbors_nos[0, new_no, k])
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_symmetry_operation, __pyx_n_s_149); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_v_new_no);
        __pyx_v_new_no = __pyx_t_8;
        __pyx_t_8 = 0;
 1928:                     k = symmetry_operation.nn_change_matrix[i][j]
        /* "water_algorithm_cython.pyx":1928
 *                 if symmetry_operation is not None:
 *                     new_no = symmetry_operation.molecule_change_matrix[i]
 *                     k = symmetry_operation.nn_change_matrix[i][j]             # <<<<<<<<<<<<<<
 *                     result += " %i-%i" % (new_no, self.nearest_neighbors_nos[0, new_no, k])
 * 
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_symmetry_operation, __pyx_n_s__nn_change_matrix); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_j); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_v_k);
        __pyx_v_k = __pyx_t_8;
        __pyx_t_8 = 0;
 1929:                     result += " %i-%i" % (new_no, self.nearest_neighbors_nos[0, new_no, k])
        /* "water_algorithm_cython.pyx":1929
 *                     new_no = symmetry_operation.molecule_change_matrix[i]
 *                     k = symmetry_operation.nn_change_matrix[i][j]
 *                     result += " %i-%i" % (new_no, self.nearest_neighbors_nos[0, new_no, k])             # <<<<<<<<<<<<<<
 * 
 *                     if self.nearest_neighbors_nos[2, new_no, k] != 13:
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        __Pyx_INCREF(__pyx_v_new_no);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_new_no);
        __Pyx_GIVEREF(__pyx_v_new_no);
        __Pyx_INCREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        __pyx_t_11 = PyObject_GetItem(__pyx_t_8, ((PyObject *)__pyx_t_3)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_new_no);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_new_no);
        __Pyx_GIVEREF(__pyx_v_new_no);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_150), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_11));
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_v_result));
        __pyx_v_result = ((PyObject*)__pyx_t_3);
        __pyx_t_3 = 0;
 1930: 
 1931:                     if self.nearest_neighbors_nos[2, new_no, k] != 13:
        /* "water_algorithm_cython.pyx":1931
 *                     result += " %i-%i" % (new_no, self.nearest_neighbors_nos[0, new_no, k])
 * 
 *                     if self.nearest_neighbors_nos[2, new_no, k] != 13:             # <<<<<<<<<<<<<<
 *                         result += "_%i" % self.nearest_neighbors_nos[2, new_no, k]
 *                         if self.nearest_neighbors_nos[2, new_no, k] < 10:
 */
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_int_2);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_2);
        __Pyx_GIVEREF(__pyx_int_2);
        __Pyx_INCREF(__pyx_v_new_no);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_new_no);
        __Pyx_GIVEREF(__pyx_v_new_no);
        __Pyx_INCREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        __pyx_t_8 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_t_11)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_RichCompare(__pyx_t_8, __pyx_int_13, Py_NE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (__pyx_t_10) {
 1932:                         result += "_%i" % self.nearest_neighbors_nos[2, new_no, k]
          /* "water_algorithm_cython.pyx":1932
 * 
 *                     if self.nearest_neighbors_nos[2, new_no, k] != 13:
 *                         result += "_%i" % self.nearest_neighbors_nos[2, new_no, k]             # <<<<<<<<<<<<<<
 *                         if self.nearest_neighbors_nos[2, new_no, k] < 10:
 *                             result += " "
 */
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(__pyx_v_new_no);
          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_new_no);
          __Pyx_GIVEREF(__pyx_v_new_no);
          __Pyx_INCREF(__pyx_v_k);
          PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_k);
          __Pyx_GIVEREF(__pyx_v_k);
          __pyx_t_3 = PyObject_GetItem(__pyx_t_11, ((PyObject *)__pyx_t_8)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_144), __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_3);
          __pyx_t_3 = 0;
 1933:                         if self.nearest_neighbors_nos[2, new_no, k] < 10:
          /* "water_algorithm_cython.pyx":1933
 *                     if self.nearest_neighbors_nos[2, new_no, k] != 13:
 *                         result += "_%i" % self.nearest_neighbors_nos[2, new_no, k]
 *                         if self.nearest_neighbors_nos[2, new_no, k] < 10:             # <<<<<<<<<<<<<<
 *                             result += " "
 *                     else:
 */
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(__pyx_v_new_no);
          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_new_no);
          __Pyx_GIVEREF(__pyx_v_new_no);
          __Pyx_INCREF(__pyx_v_k);
          PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_v_k);
          __Pyx_GIVEREF(__pyx_v_k);
          __pyx_t_11 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_t_8)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
          __pyx_t_8 = PyObject_RichCompare(__pyx_t_11, __pyx_int_10, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (__pyx_t_10) {
 1934:                             result += " "
            /* "water_algorithm_cython.pyx":1934
 *                         result += "_%i" % self.nearest_neighbors_nos[2, new_no, k]
 *                         if self.nearest_neighbors_nos[2, new_no, k] < 10:
 *                             result += " "             # <<<<<<<<<<<<<<
 *                     else:
 *                         result += "   "
 */
            __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_142)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_8));
            __Pyx_DECREF(((PyObject *)__pyx_v_result));
            __pyx_v_result = ((PyObject*)__pyx_t_8);
            __pyx_t_8 = 0;
            goto __pyx_L17;
          }
          __pyx_L17:;
          goto __pyx_L16;
        }
        /*else*/ {
 1935:                     else:
 1936:                         result += "   "
          /* "water_algorithm_cython.pyx":1936
 *                             result += " "
 *                     else:
 *                         result += "   "             # <<<<<<<<<<<<<<
 *                     if new_no < 10:
 *                         result += " "
 */
          __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_151)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_8);
          __pyx_t_8 = 0;
        }
        __pyx_L16:;
 1937:                     if new_no < 10:
        /* "water_algorithm_cython.pyx":1937
 *                     else:
 *                         result += "   "
 *                     if new_no < 10:             # <<<<<<<<<<<<<<
 *                         result += " "
 *                     if self.nearest_neighbors_nos[0, new_no, k] < 10:
 */
        __pyx_t_8 = PyObject_RichCompare(__pyx_v_new_no, __pyx_int_10, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_10) {
 1938:                         result += " "
          /* "water_algorithm_cython.pyx":1938
 *                         result += "   "
 *                     if new_no < 10:
 *                         result += " "             # <<<<<<<<<<<<<<
 *                     if self.nearest_neighbors_nos[0, new_no, k] < 10:
 *                         result += " "
 */
          __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_142)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_8);
          __pyx_t_8 = 0;
          goto __pyx_L18;
        }
        __pyx_L18:;
 1939:                     if self.nearest_neighbors_nos[0, new_no, k] < 10:
        /* "water_algorithm_cython.pyx":1939
 *                     if new_no < 10:
 *                         result += " "
 *                     if self.nearest_neighbors_nos[0, new_no, k] < 10:             # <<<<<<<<<<<<<<
 *                         result += " "
 *                     result += "  "
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        __Pyx_INCREF(__pyx_v_new_no);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_new_no);
        __Pyx_GIVEREF(__pyx_v_new_no);
        __Pyx_INCREF(__pyx_v_k);
        PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_v_k);
        __Pyx_GIVEREF(__pyx_v_k);
        __pyx_t_3 = PyObject_GetItem(__pyx_t_8, ((PyObject *)__pyx_t_11)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_RichCompare(__pyx_t_3, __pyx_int_10, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (__pyx_t_10) {
 1940:                         result += " "
          /* "water_algorithm_cython.pyx":1940
 *                         result += " "
 *                     if self.nearest_neighbors_nos[0, new_no, k] < 10:
 *                         result += " "             # <<<<<<<<<<<<<<
 *                     result += "  "
 *             result += "\n"
 */
          __pyx_t_11 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_142)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_11));
          __Pyx_DECREF(((PyObject *)__pyx_v_result));
          __pyx_v_result = ((PyObject*)__pyx_t_11);
          __pyx_t_11 = 0;
          goto __pyx_L19;
        }
        __pyx_L19:;
 1941:                     result += "  "
        /* "water_algorithm_cython.pyx":1941
 *                     if self.nearest_neighbors_nos[0, new_no, k] < 10:
 *                         result += " "
 *                     result += "  "             # <<<<<<<<<<<<<<
 *             result += "\n"
 *         print result
 */
        __pyx_t_11 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_152)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_11));
        __Pyx_DECREF(((PyObject *)__pyx_v_result));
        __pyx_v_result = ((PyObject*)__pyx_t_11);
        __pyx_t_11 = 0;
        goto __pyx_L15;
      }
      __pyx_L15:;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1942:             result += "\n"
    /* "water_algorithm_cython.pyx":1942
 *                         result += " "
 *                     result += "  "
 *             result += "\n"             # <<<<<<<<<<<<<<
 *         print result
 * 
 */
    __pyx_t_4 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_kp_s_64)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_DECREF(((PyObject *)__pyx_v_result));
    __pyx_v_result = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
  }
 1943:         print result
  /* "water_algorithm_cython.pyx":1943
 *                     result += "  "
 *             result += "\n"
 *         print result             # <<<<<<<<<<<<<<
 * 
 *     def print_nearest_neighbors_nos_wo(self, water_orientation):
 */
  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_result)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.print_nearest_neighbors_nos", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_new_no);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_77print_nearest_neighbors_nos_wo(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_77print_nearest_neighbors_nos_wo(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_nearest_neighbors_nos_wo (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_76print_nearest_neighbors_nos_wo(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_water_orientation));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1944: 
 1945:     def print_nearest_neighbors_nos_wo(self, water_orientation):
/* "water_algorithm_cython.pyx":1945
 *         print result
 * 
 *     def print_nearest_neighbors_nos_wo(self, water_orientation):             # <<<<<<<<<<<<<<
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_76print_nearest_neighbors_nos_wo(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  __Pyx_memviewslice __pyx_v_bond_variables = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("print_nearest_neighbors_nos_wo", 0);
 1946:         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":1946
 * 
 *     def print_nearest_neighbors_nos_wo(self, water_orientation):
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables)
 *         self.print_nearest_neighbors_nos(bond_variables)
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
  if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_bond_variables = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 1947:         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables)
  /* "water_algorithm_cython.pyx":1947
 *     def print_nearest_neighbors_nos_wo(self, water_orientation):
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables)             # <<<<<<<<<<<<<<
 *         self.print_nearest_neighbors_nos(bond_variables)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_water_orientation);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_3);
  if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_5, __pyx_t_6, __pyx_v_self->N, __pyx_v_bond_variables);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
 1948:         self.print_nearest_neighbors_nos(bond_variables)
  /* "water_algorithm_cython.pyx":1948
 *         cdef DTYPE2_t[:, ::1] bond_variables = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables)
 *         self.print_nearest_neighbors_nos(bond_variables)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_153); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_bond_variables, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.print_nearest_neighbors_nos_wo", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_79verify_invariants(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_79verify_invariants(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("verify_invariants (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_78verify_invariants(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_water_orientation));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1949: 
 1950: 
 1951:     def verify_invariants(self, water_orientation):
/* "water_algorithm_cython.pyx":1951
 * 
 * 
 *     def verify_invariants(self, water_orientation):             # <<<<<<<<<<<<<<
 *         if self.graph_invariants is None:
 *             self.initialize_symmetry_operations()
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_78verify_invariants(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  __Pyx_memviewslice __pyx_v_bond_variables_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_bond_variables_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_water_orientation_2 = 0;
  struct __pyx_obj_23graph_invariants_cython_Invariant *__pyx_v_invariant = 0;
  PyBoolObject *__pyx_v_valid = 0;
  PyObject *__pyx_v_new_invariants = 0;
  struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *__pyx_v_symmetry_operation = 0;
  PyObject *__pyx_v_i = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_j = NULL;
  char __pyx_v_value_1;
  char __pyx_v_value_2;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientation_2;
  __Pyx_Buffer __pyx_pybuffer_water_orientation_2;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("verify_invariants", 0);
  __pyx_pybuffer_water_orientation_2.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientation_2.refcount = 0;
  __pyx_pybuffernd_water_orientation_2.data = NULL;
  __pyx_pybuffernd_water_orientation_2.rcbuffer = &__pyx_pybuffer_water_orientation_2;
 1952:         if self.graph_invariants is None:
  /* "water_algorithm_cython.pyx":1952
 * 
 *     def verify_invariants(self, water_orientation):
 *         if self.graph_invariants is None:             # <<<<<<<<<<<<<<
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 */
  __pyx_t_1 = (__pyx_v_self->graph_invariants == ((PyObject*)Py_None));
  if (__pyx_t_1) {
 1953:             self.initialize_symmetry_operations()
    /* "water_algorithm_cython.pyx":1953
 *     def verify_invariants(self, water_orientation):
 *         if self.graph_invariants is None:
 *             self.initialize_symmetry_operations()             # <<<<<<<<<<<<<<
 *             self.load_invariants()
 * 
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->initialize_symmetry_operations(__pyx_v_self);
 1954:             self.load_invariants()
    /* "water_algorithm_cython.pyx":1954
 *         if self.graph_invariants is None:
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()             # <<<<<<<<<<<<<<
 * 
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->load_invariants(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;
 1955: 
 1956:         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":1956
 *             self.load_invariants()
 * 
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables_1)
 * 
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_bond_variables_1 = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
  __pyx_t_4 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_2);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_bond_variables_2 = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
 1957:         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables_1)
  /* "water_algorithm_cython.pyx":1957
 * 
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation, self.nearest_neighbors_nos, self.N, bond_variables_1)             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[DTYPE2_t, ndim=1] water_orientation_2
 */
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_water_orientation);
  if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_2);
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_6, __pyx_t_7, __pyx_v_self->N, __pyx_v_bond_variables_1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
 1958: 
 1959:         cdef np.ndarray[DTYPE2_t, ndim=1] water_orientation_2
 1960:         #self.print_nearest_neighbors_nos(bond_variables_1)
 1961:         #self.print_nearest_neighbors_nos(bond_variables_2)
 1962:         #self.print_nearest_neighbors_nos(symmetry_operation = symmetry_operation)
 1963:         cdef Invariant invariant
 1964:         cdef bool valid
 1965:         cdef list new_invariants = []
  /* "water_algorithm_cython.pyx":1965
 *         cdef Invariant invariant
 *         cdef bool valid
 *         cdef list new_invariants = []             # <<<<<<<<<<<<<<
 *         #cdef InvariantTerm invariant_term
 *         cdef SymmetryOperation symmetry_operation
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_new_invariants = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;
 1966:         #cdef InvariantTerm invariant_term
 1967:         cdef SymmetryOperation symmetry_operation
 1968:         for i, invariant in enumerate(self.graph_invariants):
  /* "water_algorithm_cython.pyx":1968
 *         #cdef InvariantTerm invariant_term
 *         cdef SymmetryOperation symmetry_operation
 *         for i, invariant in enumerate(self.graph_invariants):             # <<<<<<<<<<<<<<
 *             valid = True
 *             for j, symmetry_operation in enumerate(self.symmetry_operations):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_2 = __pyx_int_0;
  __pyx_t_3 = ((PyObject *)__pyx_v_self->graph_invariants); __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0;
  for (;;) {
    if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_23graph_invariants_cython_Invariant))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_invariant));
    __pyx_v_invariant = ((struct __pyx_obj_23graph_invariants_cython_Invariant *)__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_2;
    __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_4;
    __pyx_t_4 = 0;
 1969:             valid = True
    /* "water_algorithm_cython.pyx":1969
 *         cdef SymmetryOperation symmetry_operation
 *         for i, invariant in enumerate(self.graph_invariants):
 *             valid = True             # <<<<<<<<<<<<<<
 *             for j, symmetry_operation in enumerate(self.symmetry_operations):
 *                 water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, False)
 */
    __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_valid));
    __pyx_v_valid = ((PyBoolObject *)__pyx_t_4);
    __pyx_t_4 = 0;
 1970:             for j, symmetry_operation in enumerate(self.symmetry_operations):
    /* "water_algorithm_cython.pyx":1970
 *         for i, invariant in enumerate(self.graph_invariants):
 *             valid = True
 *             for j, symmetry_operation in enumerate(self.symmetry_operations):             # <<<<<<<<<<<<<<
 *                 water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, False)
 *                 get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_4 = __pyx_int_0;
    __pyx_t_9 = ((PyObject *)__pyx_v_self->symmetry_operations); __Pyx_INCREF(__pyx_t_9); __pyx_t_10 = 0;
    for (;;) {
      if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_9)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_11 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_11); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_11 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
      if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_10symmetries_25symmetry_operation_cython_SymmetryOperation))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry_operation));
      __pyx_v_symmetry_operation = ((struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_v_j);
      __pyx_v_j = __pyx_t_4;
      __pyx_t_11 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_4);
      __pyx_t_4 = __pyx_t_11;
      __pyx_t_11 = 0;
 1971:                 water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, False)
      /* "water_algorithm_cython.pyx":1971
 *             valid = True
 *             for j, symmetry_operation in enumerate(self.symmetry_operations):
 *                 water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, False)             # <<<<<<<<<<<<<<
 *                 get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 *                 value_1 = invariant._get_value(bond_variables_1.base)
 */
      __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE2_t(__pyx_v_water_orientation);
      if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE_t(__pyx_t_11);
      if (unlikely(!__pyx_t_13.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_v_symmetry_operation->__pyx_vtab)->apply(__pyx_v_symmetry_operation, __pyx_t_12, __pyx_v_self, __pyx_t_13, 0)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer);
        __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_11), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_14 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientation_2, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          }
        }
        __pyx_pybuffernd_water_orientation_2.diminfo[0].strides = __pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientation_2.diminfo[0].shape = __pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_XDECREF(((PyObject *)__pyx_v_water_orientation_2));
      __pyx_v_water_orientation_2 = ((PyArrayObject *)__pyx_t_11);
      __pyx_t_11 = 0;
 1972:                 get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
      /* "water_algorithm_cython.pyx":1972
 *             for j, symmetry_operation in enumerate(self.symmetry_operations):
 *                 water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, False)
 *                 get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)             # <<<<<<<<<<<<<<
 *                 value_1 = invariant._get_value(bond_variables_1.base)
 *                 value_2 = invariant._get_value(bond_variables_2.base)
 */
      __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_water_orientation_2));
      if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_11);
      if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_6, __pyx_t_7, __pyx_v_self->N, __pyx_v_bond_variables_2);
      __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
 1973:                 value_1 = invariant._get_value(bond_variables_1.base)
      /* "water_algorithm_cython.pyx":1973
 *                 water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, False)
 *                 get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 *                 value_1 = invariant._get_value(bond_variables_1.base)             # <<<<<<<<<<<<<<
 *                 value_2 = invariant._get_value(bond_variables_2.base)
 *                 if value_1 != value_2:
 */
      __pyx_t_11 = __pyx_memoryview_fromslice(__pyx_v_bond_variables_1, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s__base); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_19 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_int8_t(__pyx_t_18);
      if (unlikely(!__pyx_t_19.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_v_value_1 = ((struct __pyx_vtabstruct_23graph_invariants_cython_Invariant *)__pyx_v_invariant->__pyx_vtab)->_get_value(__pyx_v_invariant, __pyx_t_19);
      __PYX_XDEC_MEMVIEW(&__pyx_t_19, 1);
 1974:                 value_2 = invariant._get_value(bond_variables_2.base)
      /* "water_algorithm_cython.pyx":1974
 *                 get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 *                 value_1 = invariant._get_value(bond_variables_1.base)
 *                 value_2 = invariant._get_value(bond_variables_2.base)             # <<<<<<<<<<<<<<
 *                 if value_1 != value_2:
 * 
 */
      __pyx_t_18 = __pyx_memoryview_fromslice(__pyx_v_bond_variables_2, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s__base); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_t_19 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_int8_t(__pyx_t_11);
      if (unlikely(!__pyx_t_19.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_v_value_2 = ((struct __pyx_vtabstruct_23graph_invariants_cython_Invariant *)__pyx_v_invariant->__pyx_vtab)->_get_value(__pyx_v_invariant, __pyx_t_19);
      __PYX_XDEC_MEMVIEW(&__pyx_t_19, 1);
 1975:                 if value_1 != value_2:
      /* "water_algorithm_cython.pyx":1975
 *                 value_1 = invariant._get_value(bond_variables_1.base)
 *                 value_2 = invariant._get_value(bond_variables_2.base)
 *                 if value_1 != value_2:             # <<<<<<<<<<<<<<
 * 
 *                     print "------------------------"
 */
      __pyx_t_1 = (__pyx_v_value_1 != __pyx_v_value_2);
      if (__pyx_t_1) {
 1976: 
 1977:                     print "------------------------"
        /* "water_algorithm_cython.pyx":1977
 *                 if value_1 != value_2:
 * 
 *                     print "------------------------"             # <<<<<<<<<<<<<<
 *                     print invariant
 *                     print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 */
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_154)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1978:                     print invariant
        /* "water_algorithm_cython.pyx":1978
 * 
 *                     print "------------------------"
 *                     print invariant             # <<<<<<<<<<<<<<
 *                     print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                     print symmetry_operation
 */
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_invariant)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1979:                     print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
        /* "water_algorithm_cython.pyx":1979
 *                     print "------------------------"
 *                     print invariant
 *                     print "Invariant %i values differ %i, %i" % (i, value_1, value_2)             # <<<<<<<<<<<<<<
 *                     print symmetry_operation
 *                     valid = False
 */
        __pyx_t_11 = PyInt_FromLong(__pyx_v_value_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_18 = PyInt_FromLong(__pyx_v_value_2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_20 = PyTuple_New(3); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_INCREF(__pyx_v_i);
        PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_i);
        __Pyx_GIVEREF(__pyx_v_i);
        PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_18);
        __Pyx_GIVEREF(__pyx_t_18);
        __pyx_t_11 = 0;
        __pyx_t_18 = 0;
        __pyx_t_18 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_155), ((PyObject *)__pyx_t_20)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __Pyx_DECREF(((PyObject *)__pyx_t_20)); __pyx_t_20 = 0;
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_18)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
 1980:                     print symmetry_operation
        /* "water_algorithm_cython.pyx":1980
 *                     print invariant
 *                     print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                     print symmetry_operation             # <<<<<<<<<<<<<<
 *                     valid = False
 *                     break
 */
        if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_symmetry_operation)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 1981:                     valid = False
        /* "water_algorithm_cython.pyx":1981
 *                     print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                     print symmetry_operation
 *                     valid = False             # <<<<<<<<<<<<<<
 *                     break
 *                     #check_value1 =  self.generate_graph_invariant_value(water_orientation, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 */
        __pyx_t_18 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        if (!(likely(__Pyx_TypeTest(__pyx_t_18, __pyx_ptype_7cpython_4bool_bool)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_v_valid));
        __pyx_v_valid = ((PyBoolObject *)__pyx_t_18);
        __pyx_t_18 = 0;
 1982:                     break
        /* "water_algorithm_cython.pyx":1982
 *                     print symmetry_operation
 *                     valid = False
 *                     break             # <<<<<<<<<<<<<<
 *                     #check_value1 =  self.generate_graph_invariant_value(water_orientation, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                     #print "Value from manual evaluation %i" % check_value1
 */
        goto __pyx_L7_break;
        goto __pyx_L8;
      }
      __pyx_L8:;
    }
    __pyx_L7_break:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 1983:                     #check_value1 =  self.generate_graph_invariant_value(water_orientation, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 1984:                     #print "Value from manual evaluation %i" % check_value1
 1985:                     #assert check_value1 == value_1
 1986:                     #check_value2 = self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 1987:                     #print "Value from manual evaluation %i" % check_value2
 1988:                     #assert check_value1 == check_value2
 1989:                     #raw_input()
 1990:                     #for invariant_term in invariant.invariant_terms:
 1991:                     #    value_1 = invariant_term.get_value(bond_variables_1)
 1992:                     #    value_2 = invariant_term.get_value(bond_variables_2)
 1993:                     #    if value_1 != value_2:
 1994:                     #        print "Invariant term (%s) values differ %i, %i" % (invariant_term, value_1, value_2)
 1995: 
 1996:             if valid:
    /* "water_algorithm_cython.pyx":1996
 *                     #        print "Invariant term (%s) values differ %i, %i" % (invariant_term, value_1, value_2)
 * 
 *             if valid:             # <<<<<<<<<<<<<<
 *                 new_invariants.append(invariant)
 *         self.graph_invariants = new_invariants
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_valid)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_1) {
 1997:                 new_invariants.append(invariant)
      /* "water_algorithm_cython.pyx":1997
 * 
 *             if valid:
 *                 new_invariants.append(invariant)             # <<<<<<<<<<<<<<
 *         self.graph_invariants = new_invariants
 * 
 */
      __pyx_t_21 = __Pyx_PyList_Append(__pyx_v_new_invariants, ((PyObject *)__pyx_v_invariant)); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1997; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L9;
    }
    __pyx_L9:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 1998:         self.graph_invariants = new_invariants
  /* "water_algorithm_cython.pyx":1998
 *             if valid:
 *                 new_invariants.append(invariant)
 *         self.graph_invariants = new_invariants             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_new_invariants));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_new_invariants));
  __Pyx_GOTREF(__pyx_v_self->graph_invariants);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->graph_invariants));
  __pyx_v_self->graph_invariants = __pyx_v_new_invariants;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __Pyx_XDECREF(__pyx_t_18);
  __PYX_XDEC_MEMVIEW(&__pyx_t_19, 1);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.verify_invariants", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables_1, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables_2, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientation_2);
  __Pyx_XDECREF((PyObject *)__pyx_v_invariant);
  __Pyx_XDECREF((PyObject *)__pyx_v_valid);
  __Pyx_XDECREF(__pyx_v_new_invariants);
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry_operation);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_81generate_graph_invariant_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_81generate_graph_invariant_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_water_orientation = 0;
  PyObject *__pyx_v_i = 0;
  PyObject *__pyx_v_j = 0;
  PyObject *__pyx_v_k = 0;
  PyObject *__pyx_v_l = 0;
  PyObject *__pyx_v_axis1 = 0;
  PyObject *__pyx_v_axis2 = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("generate_graph_invariant_value (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_orientation,&__pyx_n_s__i,&__pyx_n_s__j,&__pyx_n_s__k,&__pyx_n_s__l,&__pyx_n_s__axis1,&__pyx_n_s__axis2,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[5] = ((PyObject *)__pyx_int_13);
    values[6] = ((PyObject *)__pyx_int_13);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("generate_graph_invariant_value", 0, 5, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("generate_graph_invariant_value", 0, 5, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("generate_graph_invariant_value", 0, 5, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__l)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("generate_graph_invariant_value", 0, 5, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__axis1);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__axis2);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "generate_graph_invariant_value") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_water_orientation = values[0];
    __pyx_v_i = values[1];
    __pyx_v_j = values[2];
    __pyx_v_k = values[3];
    __pyx_v_l = values[4];
    __pyx_v_axis1 = values[5];
    __pyx_v_axis2 = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("generate_graph_invariant_value", 0, 5, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.generate_graph_invariant_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_80generate_graph_invariant_value(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_water_orientation, __pyx_v_i, __pyx_v_j, __pyx_v_k, __pyx_v_l, __pyx_v_axis1, __pyx_v_axis2);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 1999: 
 2000: 
 2001:     def generate_graph_invariant_value(self, water_orientation, i, j, k, l, axis1 = 13, axis2 = 13):
/* "water_algorithm_cython.pyx":2001
 * 
 * 
 *     def generate_graph_invariant_value(self, water_orientation, i, j, k, l, axis1 = 13, axis2 = 13):             # <<<<<<<<<<<<<<
 *         cdef SymmetryOperation symmetry_operation
 *         cdef  DTYPE2_t[:, ::1] bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_80generate_graph_invariant_value(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientation, PyObject *__pyx_v_i, PyObject *__pyx_v_j, PyObject *__pyx_v_k, PyObject *__pyx_v_l, PyObject *__pyx_v_axis1, PyObject *__pyx_v_axis2) {
  struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *__pyx_v_symmetry_operation = 0;
  __Pyx_memviewslice __pyx_v_bond_variables_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_water_orientation_2 = 0;
  PyObject *__pyx_v_m = NULL;
  PyObject *__pyx_v_nn = NULL;
  PyObject *__pyx_v_index_j = NULL;
  PyObject *__pyx_v_n = NULL;
  PyObject *__pyx_v_index_l = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_invariant_str = 0;
  CYTHON_UNUSED PyObject *__pyx_v_value_str = 0;
  int __pyx_v_inverse;
  PyArrayObject *__pyx_v_indeces = 0;
  PyObject *__pyx_v_current_value = NULL;
  PyObject *__pyx_v_order_list = NULL;
  long __pyx_v_order_of_invariant;
  PyObject *__pyx_v_N = NULL;
  PyObject *__pyx_v_multipliers = NULL;
  PyObject *__pyx_v_constants = NULL;
  PyObject *__pyx_v_constant = NULL;
  PyObject *__pyx_v_multiplier = NULL;
  PyObject *__pyx_v_index = NULL;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_new_index_2;
  PyObject *__pyx_v_np_order_list = NULL;
  long __pyx_v_counter;
  PyObject *__pyx_v_lists = NULL;
  PyObject *__pyx_v_ind = NULL;
  PyObject *__pyx_v_previous_term = NULL;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_v_bv = NULL;
  PyObject *__pyx_v_old_value = NULL;
  PyObject *__pyx_v_old_value_str = NULL;
  PyObject *__pyx_v_mul = NULL;
  PyObject *__pyx_v_current_term = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indeces;
  __Pyx_Buffer __pyx_pybuffer_indeces;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientation_2;
  __Pyx_Buffer __pyx_pybuffer_water_orientation_2;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("generate_graph_invariant_value", 0);
  __Pyx_INCREF(__pyx_v_i);
  __Pyx_INCREF(__pyx_v_l);
  __pyx_pybuffer_water_orientation_2.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientation_2.refcount = 0;
  __pyx_pybuffernd_water_orientation_2.data = NULL;
  __pyx_pybuffernd_water_orientation_2.rcbuffer = &__pyx_pybuffer_water_orientation_2;
  __pyx_pybuffer_indeces.pybuffer.buf = NULL;
  __pyx_pybuffer_indeces.refcount = 0;
  __pyx_pybuffernd_indeces.data = NULL;
  __pyx_pybuffernd_indeces.rcbuffer = &__pyx_pybuffer_indeces;
 2002:         cdef SymmetryOperation symmetry_operation
 2003:         cdef  DTYPE2_t[:, ::1] bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":2003
 *     def generate_graph_invariant_value(self, water_orientation, i, j, k, l, axis1 = 13, axis2 = 13):
 *         cdef SymmetryOperation symmetry_operation
 *         cdef  DTYPE2_t[:, ::1] bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         #cdef  DTYPE2_t[:, ::1] bv = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         cdef np.ndarray[DTYPE2_t, ndim=1] water_orientation_2
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_3);
  if (unlikely(!__pyx_t_4.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_bond_variables_2 = __pyx_t_4;
  __pyx_t_4.memview = NULL;
  __pyx_t_4.data = NULL;
 2004:         #cdef  DTYPE2_t[:, ::1] bv = np.ndarray((self.N, 4), dtype=DTYPE2)
 2005:         cdef np.ndarray[DTYPE2_t, ndim=1] water_orientation_2
 2006:         for m, nn in enumerate(self.nearest_neighbors_nos[0][i]):
  /* "water_algorithm_cython.pyx":2006
 *         #cdef  DTYPE2_t[:, ::1] bv = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         cdef np.ndarray[DTYPE2_t, ndim=1] water_orientation_2
 *         for m, nn in enumerate(self.nearest_neighbors_nos[0][i]):             # <<<<<<<<<<<<<<
 *             if nn == j and self.nearest_neighbors_nos[2][i][m] == axis1:
 *                 index_j = m
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_2 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF(__pyx_v_nn);
    __pyx_v_nn = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF(__pyx_v_m);
    __pyx_v_m = __pyx_t_3;
    __pyx_t_2 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_2;
    __pyx_t_2 = 0;
 2007:             if nn == j and self.nearest_neighbors_nos[2][i][m] == axis1:
    /* "water_algorithm_cython.pyx":2007
 *         cdef np.ndarray[DTYPE2_t, ndim=1] water_orientation_2
 *         for m, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *             if nn == j and self.nearest_neighbors_nos[2][i][m] == axis1:             # <<<<<<<<<<<<<<
 *                 index_j = m
 *         for n, nn in enumerate(self.nearest_neighbors_nos[0][k]):
 */
    __pyx_t_2 = PyObject_RichCompare(__pyx_v_nn, __pyx_v_j, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_7) {
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_2, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(__pyx_t_8, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_v_m); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_RichCompare(__pyx_t_8, __pyx_v_axis1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_10 = __pyx_t_9;
    } else {
      __pyx_t_10 = __pyx_t_7;
    }
    if (__pyx_t_10) {
 2008:                 index_j = m
      /* "water_algorithm_cython.pyx":2008
 *         for m, nn in enumerate(self.nearest_neighbors_nos[0][i]):
 *             if nn == j and self.nearest_neighbors_nos[2][i][m] == axis1:
 *                 index_j = m             # <<<<<<<<<<<<<<
 *         for n, nn in enumerate(self.nearest_neighbors_nos[0][k]):
 *             if nn == l and self.nearest_neighbors_nos[2][k][n] == axis2:
 */
      __Pyx_INCREF(__pyx_v_m);
      __Pyx_XDECREF(__pyx_v_index_j);
      __pyx_v_index_j = __pyx_v_m;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2009:         for n, nn in enumerate(self.nearest_neighbors_nos[0][k]):
  /* "water_algorithm_cython.pyx":2009
 *             if nn == j and self.nearest_neighbors_nos[2][i][m] == axis1:
 *                 index_j = m
 *         for n, nn in enumerate(self.nearest_neighbors_nos[0][k]):             # <<<<<<<<<<<<<<
 *             if nn == l and self.nearest_neighbors_nos[2][k][n] == axis2:
 *                 index_l = n
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_v_k); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_6(__pyx_t_2);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_nn);
    __pyx_v_nn = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF(__pyx_v_n);
    __pyx_v_n = __pyx_t_3;
    __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
 2010:             if nn == l and self.nearest_neighbors_nos[2][k][n] == axis2:
    /* "water_algorithm_cython.pyx":2010
 *                 index_j = m
 *         for n, nn in enumerate(self.nearest_neighbors_nos[0][k]):
 *             if nn == l and self.nearest_neighbors_nos[2][k][n] == axis2:             # <<<<<<<<<<<<<<
 *                 index_l = n
 *         value = 0
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_nn, __pyx_v_l, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_10) {
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_1, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_GetItem(__pyx_t_8, __pyx_v_k); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_n); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_RichCompare(__pyx_t_8, __pyx_v_axis2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __pyx_t_7;
    } else {
      __pyx_t_9 = __pyx_t_10;
    }
    if (__pyx_t_9) {
 2011:                 index_l = n
      /* "water_algorithm_cython.pyx":2011
 *         for n, nn in enumerate(self.nearest_neighbors_nos[0][k]):
 *             if nn == l and self.nearest_neighbors_nos[2][k][n] == axis2:
 *                 index_l = n             # <<<<<<<<<<<<<<
 *         value = 0
 *         cdef str invariant_str = ""
 */
      __Pyx_INCREF(__pyx_v_n);
      __Pyx_XDECREF(__pyx_v_index_l);
      __pyx_v_index_l = __pyx_v_n;
      goto __pyx_L8;
    }
    __pyx_L8:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2012:         value = 0
  /* "water_algorithm_cython.pyx":2012
 *             if nn == l and self.nearest_neighbors_nos[2][k][n] == axis2:
 *                 index_l = n
 *         value = 0             # <<<<<<<<<<<<<<
 *         cdef str invariant_str = ""
 *         cdef str value_str = ""
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_value = __pyx_int_0;
 2013:         cdef str invariant_str = ""
  /* "water_algorithm_cython.pyx":2013
 *                 index_l = n
 *         value = 0
 *         cdef str invariant_str = ""             # <<<<<<<<<<<<<<
 *         cdef str value_str = ""
 *         inverse = False
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  __pyx_v_invariant_str = __pyx_kp_s_1;
 2014:         cdef str value_str = ""
  /* "water_algorithm_cython.pyx":2014
 *         value = 0
 *         cdef str invariant_str = ""
 *         cdef str value_str = ""             # <<<<<<<<<<<<<<
 *         inverse = False
 *         cdef np.ndarray[DTYPE2_t, ndim=3] indeces = np.zeros((len(self.symmetry_operations), 2, 3), dtype=DTYPE2)
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  __pyx_v_value_str = __pyx_kp_s_1;
 2015:         inverse = False
  /* "water_algorithm_cython.pyx":2015
 *         cdef str invariant_str = ""
 *         cdef str value_str = ""
 *         inverse = False             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[DTYPE2_t, ndim=3] indeces = np.zeros((len(self.symmetry_operations), 2, 3), dtype=DTYPE2)
 *         #print "b_{%i, %i} * b_{%i, %i}" % (i, index_j, k, index_l)
 */
  __pyx_v_inverse = 0;
 2016:         cdef np.ndarray[DTYPE2_t, ndim=3] indeces = np.zeros((len(self.symmetry_operations), 2, 3), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":2016
 *         cdef str value_str = ""
 *         inverse = False
 *         cdef np.ndarray[DTYPE2_t, ndim=3] indeces = np.zeros((len(self.symmetry_operations), 2, 3), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         #print "b_{%i, %i} * b_{%i, %i}" % (i, index_j, k, index_l)
 *         for m, symmetry_operation in enumerate(self.symmetry_operations):
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((PyObject *)__pyx_v_self->symmetry_operations);
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_5 = PyList_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indeces.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_indeces = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_indeces.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2016; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_indeces.diminfo[0].strides = __pyx_pybuffernd_indeces.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indeces.diminfo[0].shape = __pyx_pybuffernd_indeces.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indeces.diminfo[1].strides = __pyx_pybuffernd_indeces.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indeces.diminfo[1].shape = __pyx_pybuffernd_indeces.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_indeces.diminfo[2].strides = __pyx_pybuffernd_indeces.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_indeces.diminfo[2].shape = __pyx_pybuffernd_indeces.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_11 = 0;
  __pyx_v_indeces = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
 2017:         #print "b_{%i, %i} * b_{%i, %i}" % (i, index_j, k, index_l)
 2018:         for m, symmetry_operation in enumerate(self.symmetry_operations):
  /* "water_algorithm_cython.pyx":2018
 *         cdef np.ndarray[DTYPE2_t, ndim=3] indeces = np.zeros((len(self.symmetry_operations), 2, 3), dtype=DTYPE2)
 *         #print "b_{%i, %i} * b_{%i, %i}" % (i, index_j, k, index_l)
 *         for m, symmetry_operation in enumerate(self.symmetry_operations):             # <<<<<<<<<<<<<<
 *             #print symmetry_operation.molecule_change_matrix
 *             #print symmetry_operation.nn_change_matrix
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_8 = __pyx_int_0;
  __pyx_t_1 = ((PyObject *)__pyx_v_self->symmetry_operations); __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_10symmetries_25symmetry_operation_cython_SymmetryOperation))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_symmetry_operation));
    __pyx_v_symmetry_operation = ((struct __pyx_obj_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_XDECREF(__pyx_v_m);
    __pyx_v_m = __pyx_t_8;
    __pyx_t_3 = PyNumber_Add(__pyx_t_8, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8);
    __pyx_t_8 = __pyx_t_3;
    __pyx_t_3 = 0;
 2019:             #print symmetry_operation.molecule_change_matrix
 2020:             #print symmetry_operation.nn_change_matrix
 2021: 
 2022:             water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, True)
    /* "water_algorithm_cython.pyx":2022
 *             #print symmetry_operation.nn_change_matrix
 * 
 *             water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, True)             # <<<<<<<<<<<<<<
 *             get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 * 
 */
    __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE2_t(__pyx_v_water_orientation);
    if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_10symmetries_25symmetry_operation_cython_DTYPE_t(__pyx_t_3);
    if (unlikely(!__pyx_t_13.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_10symmetries_25symmetry_operation_cython_SymmetryOperation *)__pyx_v_symmetry_operation->__pyx_vtab)->apply(__pyx_v_symmetry_operation, __pyx_t_12, __pyx_v_self, __pyx_t_13, 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_3), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientation_2, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_water_orientation_2.diminfo[0].strides = __pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientation_2.diminfo[0].shape = __pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_XDECREF(((PyObject *)__pyx_v_water_orientation_2));
    __pyx_v_water_orientation_2 = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
 2023:             get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
    /* "water_algorithm_cython.pyx":2023
 * 
 *             water_orientation_2 = symmetry_operation.apply(water_orientation,  self, self.nearest_neighbors_nos, True)
 *             get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)             # <<<<<<<<<<<<<<
 * 
 *             current_value = bond_variables_2[i][index_j] * bond_variables_2[k][index_l]
 */
    __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(((PyObject *)__pyx_v_water_orientation_2));
    if (unlikely(!__pyx_t_18.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_19 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_3);
    if (unlikely(!__pyx_t_19.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_18, __pyx_t_19, __pyx_v_self->N, __pyx_v_bond_variables_2);
    __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_19, 1);
 2024: 
 2025:             current_value = bond_variables_2[i][index_j] * bond_variables_2[k][index_l]
    /* "water_algorithm_cython.pyx":2025
 *             get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 * 
 *             current_value = bond_variables_2[i][index_j] * bond_variables_2[k][index_l]             # <<<<<<<<<<<<<<
 *             value += current_value
 *             if inverse:
 */
    __pyx_t_20 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_20 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = -1;
    __pyx_t_21.data = __pyx_v_bond_variables_2.data;
    __pyx_t_21.memview = __pyx_v_bond_variables_2.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_21, 0);
    {
    Py_ssize_t __pyx_tmp_idx = __pyx_t_20;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_bond_variables_2.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_bond_variables_2.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_21.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_21.shape[0] = __pyx_v_bond_variables_2.shape[1];
__pyx_t_21.strides[0] = __pyx_v_bond_variables_2.strides[1];
    __pyx_t_21.suboffsets[0] = -1;

if (unlikely(!__pyx_v_index_j)) { __Pyx_RaiseUnboundLocalError("index_j"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_20 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index_j); if (unlikely((__pyx_t_20 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_22 = __pyx_t_20;
    __pyx_t_23 = __Pyx_PyIndex_AsSsize_t(__pyx_v_k); if (unlikely((__pyx_t_23 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_14 = -1;
    __pyx_t_24.data = __pyx_v_bond_variables_2.data;
    __pyx_t_24.memview = __pyx_v_bond_variables_2.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_24, 0);
    {
    Py_ssize_t __pyx_tmp_idx = __pyx_t_23;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_bond_variables_2.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_bond_variables_2.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
        __pyx_t_24.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_24.shape[0] = __pyx_v_bond_variables_2.shape[1];
__pyx_t_24.strides[0] = __pyx_v_bond_variables_2.strides[1];
    __pyx_t_24.suboffsets[0] = -1;

if (unlikely(!__pyx_v_index_l)) { __Pyx_RaiseUnboundLocalError("index_l"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
    __pyx_t_23 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index_l); if (unlikely((__pyx_t_23 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_25 = __pyx_t_23;
    __pyx_t_3 = PyInt_FromLong(((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_t_21.data) + __pyx_t_22)) ))) * (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_t_24.data) + __pyx_t_25)) ))))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
    __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1);
    __Pyx_XDECREF(__pyx_v_current_value);
    __pyx_v_current_value = __pyx_t_3;
    __pyx_t_3 = 0;
 2026:             value += current_value
    /* "water_algorithm_cython.pyx":2026
 * 
 *             current_value = bond_variables_2[i][index_j] * bond_variables_2[k][index_l]
 *             value += current_value             # <<<<<<<<<<<<<<
 *             if inverse:
 *                 indeces[m, 0] = np.array([symmetry_operation.inverse_molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]]], dtype=DTYPE2)
 */
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_value, __pyx_v_current_value); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_value);
    __pyx_v_value = __pyx_t_3;
    __pyx_t_3 = 0;
 2027:             if inverse:
    /* "water_algorithm_cython.pyx":2027
 *             current_value = bond_variables_2[i][index_j] * bond_variables_2[k][index_l]
 *             value += current_value
 *             if inverse:             # <<<<<<<<<<<<<<
 *                 indeces[m, 0] = np.array([symmetry_operation.inverse_molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]]], dtype=DTYPE2)
 *                 indeces[m, 1] = np.array([symmetry_operation.inverse_molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]]], dtype=DTYPE2)
 */
    if (__pyx_v_inverse) {
 2028:                 indeces[m, 0] = np.array([symmetry_operation.inverse_molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]]], dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":2028
 *             value += current_value
 *             if inverse:
 *                 indeces[m, 0] = np.array([symmetry_operation.inverse_molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                 indeces[m, 1] = np.array([symmetry_operation.inverse_molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]]], dtype=DTYPE2)
 * 
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_molecule_change_matrix), __pyx_v_i); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_27 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_molecule_change_matrix), __pyx_v_i); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_28 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_nn_change_matrix), __pyx_v_i); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_29 = PyObject_GetItem(__pyx_t_28, __pyx_v_index_j); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __pyx_t_28 = PyTuple_New(3); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_28, 1, __pyx_t_27);
      __Pyx_GIVEREF(__pyx_t_27);
      PyTuple_SET_ITEM(__pyx_t_28, 2, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      __pyx_t_27 = 0;
      __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_GetItem(__pyx_t_26, ((PyObject *)__pyx_t_28)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_28)); __pyx_t_28 = 0;
      __pyx_t_28 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_26 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_molecule_change_matrix), __pyx_v_i); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_27 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_nn_change_matrix), __pyx_v_i); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_30 = PyObject_GetItem(__pyx_t_27, __pyx_v_index_j); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = PyTuple_New(3); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_INCREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      PyTuple_SET_ITEM(__pyx_t_27, 2, __pyx_t_30);
      __Pyx_GIVEREF(__pyx_t_30);
      __pyx_t_26 = 0;
      __pyx_t_30 = 0;
      __pyx_t_30 = PyObject_GetItem(__pyx_t_28, ((PyObject *)__pyx_t_27)); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
      __pyx_t_27 = PyList_New(3); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      PyList_SET_ITEM(__pyx_t_27, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_27, 1, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      PyList_SET_ITEM(__pyx_t_27, 2, __pyx_t_30);
      __Pyx_GIVEREF(__pyx_t_30);
      __pyx_t_3 = 0;
      __pyx_t_29 = 0;
      __pyx_t_30 = 0;
      __pyx_t_30 = PyTuple_New(1); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      PyTuple_SET_ITEM(__pyx_t_30, 0, ((PyObject *)__pyx_t_27));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_27));
      __pyx_t_27 = 0;
      __pyx_t_27 = PyDict_New(); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_27));
      __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      if (PyDict_SetItem(__pyx_t_27, ((PyObject *)__pyx_n_s__dtype), __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_30), ((PyObject *)__pyx_t_27)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
      __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_27), __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
 2029:                 indeces[m, 1] = np.array([symmetry_operation.inverse_molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]]], dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":2029
 *             if inverse:
 *                 indeces[m, 0] = np.array([symmetry_operation.inverse_molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[i], symmetry_operation.inverse_nn_change_matrix[i][index_j]]], dtype=DTYPE2)
 *                 indeces[m, 1] = np.array([symmetry_operation.inverse_molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.inverse_molecule_change_matrix[k], symmetry_operation.inverse_nn_change_matrix[k][index_l]]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 * 
 *                 #value_str += " (%i * %i = %i) " % (bond_variables_2[i][index_j], bond_variables_2[k][index_l], current_value)
 */
      __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s__array); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_molecule_change_matrix), __pyx_v_k); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_30 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_molecule_change_matrix), __pyx_v_k); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_nn_change_matrix), __pyx_v_k); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_28 = PyObject_GetItem(__pyx_t_3, __pyx_v_index_l); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_28);
      __Pyx_GIVEREF(__pyx_t_28);
      __pyx_t_2 = 0;
      __pyx_t_28 = 0;
      __pyx_t_28 = PyObject_GetItem(__pyx_t_30, ((PyObject *)__pyx_t_3)); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_30 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_molecule_change_matrix), __pyx_v_k); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->inverse_nn_change_matrix), __pyx_v_k); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_26 = PyObject_GetItem(__pyx_t_2, __pyx_v_index_l); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_30);
      __Pyx_GIVEREF(__pyx_t_30);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      __pyx_t_30 = 0;
      __pyx_t_26 = 0;
      __pyx_t_26 = PyObject_GetItem(__pyx_t_3, ((PyObject *)__pyx_t_2)); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_28);
      __Pyx_GIVEREF(__pyx_t_28);
      PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      __pyx_t_29 = 0;
      __pyx_t_28 = 0;
      __pyx_t_26 = 0;
      __pyx_t_26 = PyTuple_New(1); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      PyTuple_SET_ITEM(__pyx_t_26, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_28) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __pyx_t_28 = PyObject_Call(__pyx_t_27, ((PyObject *)__pyx_t_26), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_26)); __pyx_t_26 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_2), __pyx_t_28) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      goto __pyx_L11;
    }
    /*else*/ {
 2030: 
 2031:                 #value_str += " (%i * %i = %i) " % (bond_variables_2[i][index_j], bond_variables_2[k][index_l], current_value)
 2032:                 #invariant_str += "(%i), " % current_value
 2033:             else:
 2034:                 indeces[m, 0] = np.array([symmetry_operation.molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]]], dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":2034
 *                 #invariant_str += "(%i), " % current_value
 *             else:
 *                 indeces[m, 0] = np.array([symmetry_operation.molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                 indeces[m, 1] = np.array([symmetry_operation.molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]]], dtype=DTYPE2)
 *         order_list = []
 */
      __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __pyx_t_28 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix), __pyx_v_i); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_27 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix), __pyx_v_i); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_29 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix), __pyx_v_i); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_3 = PyObject_GetItem(__pyx_t_29, __pyx_v_index_j); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = PyTuple_New(3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_t_27);
      __Pyx_GIVEREF(__pyx_t_27);
      PyTuple_SET_ITEM(__pyx_t_29, 2, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_27 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(__pyx_t_26, ((PyObject *)__pyx_t_29)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
      __pyx_t_29 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_26 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix), __pyx_v_i); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_27 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix), __pyx_v_i); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_30 = PyObject_GetItem(__pyx_t_27, __pyx_v_index_j); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = PyTuple_New(3); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_INCREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      PyTuple_SET_ITEM(__pyx_t_27, 2, __pyx_t_30);
      __Pyx_GIVEREF(__pyx_t_30);
      __pyx_t_26 = 0;
      __pyx_t_30 = 0;
      __pyx_t_30 = PyObject_GetItem(__pyx_t_29, ((PyObject *)__pyx_t_27)); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
      __pyx_t_27 = PyList_New(3); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      PyList_SET_ITEM(__pyx_t_27, 0, __pyx_t_28);
      __Pyx_GIVEREF(__pyx_t_28);
      PyList_SET_ITEM(__pyx_t_27, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_27, 2, __pyx_t_30);
      __Pyx_GIVEREF(__pyx_t_30);
      __pyx_t_28 = 0;
      __pyx_t_3 = 0;
      __pyx_t_30 = 0;
      __pyx_t_30 = PyTuple_New(1); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      PyTuple_SET_ITEM(__pyx_t_30, 0, ((PyObject *)__pyx_t_27));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_27));
      __pyx_t_27 = 0;
      __pyx_t_27 = PyDict_New(); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_27));
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_27, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_30), ((PyObject *)__pyx_t_27)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_30)); __pyx_t_30 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
      __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_27), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2035:                 indeces[m, 1] = np.array([symmetry_operation.molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]]], dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":2035
 *             else:
 *                 indeces[m, 0] = np.array([symmetry_operation.molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]]], dtype=DTYPE2)
 *                 indeces[m, 1] = np.array([symmetry_operation.molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         order_list = []
 *         order_of_invariant = 2
 */
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix), __pyx_v_k); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_30 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix), __pyx_v_k); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_28 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix), __pyx_v_k); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_29 = PyObject_GetItem(__pyx_t_28, __pyx_v_index_l); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __pyx_t_28 = PyTuple_New(3); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_28, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_28, 2, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      __pyx_t_2 = 0;
      __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_GetItem(__pyx_t_30, ((PyObject *)__pyx_t_28)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_28)); __pyx_t_28 = 0;
      __pyx_t_28 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_28);
      __pyx_t_30 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->molecule_change_matrix), __pyx_v_k); if (!__pyx_t_30) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_30);
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_symmetry_operation->nn_change_matrix), __pyx_v_k); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_26 = PyObject_GetItem(__pyx_t_2, __pyx_v_index_l); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_2);
      __Pyx_GIVEREF(__pyx_int_2);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_30);
      __Pyx_GIVEREF(__pyx_t_30);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      __pyx_t_30 = 0;
      __pyx_t_26 = 0;
      __pyx_t_26 = PyObject_GetItem(__pyx_t_28, ((PyObject *)__pyx_t_2)); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      __pyx_t_3 = 0;
      __pyx_t_29 = 0;
      __pyx_t_26 = 0;
      __pyx_t_26 = PyTuple_New(1); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      PyTuple_SET_ITEM(__pyx_t_26, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_Call(__pyx_t_27, ((PyObject *)__pyx_t_26), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_26)); __pyx_t_26 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_2), __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    }
    __pyx_L11:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 2036:         order_list = []
  /* "water_algorithm_cython.pyx":2036
 *                 indeces[m, 0] = np.array([symmetry_operation.molecule_change_matrix[i], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[i], symmetry_operation.nn_change_matrix[i][index_j]]], dtype=DTYPE2)
 *                 indeces[m, 1] = np.array([symmetry_operation.molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]]], dtype=DTYPE2)
 *         order_list = []             # <<<<<<<<<<<<<<
 *         order_of_invariant = 2
 *         N = len(indeces)
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_order_list = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;
 2037:         order_of_invariant = 2
  /* "water_algorithm_cython.pyx":2037
 *                 indeces[m, 1] = np.array([symmetry_operation.molecule_change_matrix[k], self.nearest_neighbors_nos[0, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]], self.nearest_neighbors_nos[2, symmetry_operation.molecule_change_matrix[k], symmetry_operation.nn_change_matrix[k][index_l]]], dtype=DTYPE2)
 *         order_list = []
 *         order_of_invariant = 2             # <<<<<<<<<<<<<<
 *         N = len(indeces)
 *         multipliers = []
 */
  __pyx_v_order_of_invariant = 2;
 2038:         N = len(indeces)
  /* "water_algorithm_cython.pyx":2038
 *         order_list = []
 *         order_of_invariant = 2
 *         N = len(indeces)             # <<<<<<<<<<<<<<
 *         multipliers = []
 *         constants = []
 */
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_indeces)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_N = __pyx_t_8;
  __pyx_t_8 = 0;
 2039:         multipliers = []
  /* "water_algorithm_cython.pyx":2039
 *         order_of_invariant = 2
 *         N = len(indeces)
 *         multipliers = []             # <<<<<<<<<<<<<<
 *         constants = []
 *         for m from 0 <= m < N:
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_multipliers = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;
 2040:         constants = []
  /* "water_algorithm_cython.pyx":2040
 *         N = len(indeces)
 *         multipliers = []
 *         constants = []             # <<<<<<<<<<<<<<
 *         for m from 0 <= m < N:
 *             constant = False
 */
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_constants = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;
 2041:         for m from 0 <= m < N:
  /* "water_algorithm_cython.pyx":2041
 *         multipliers = []
 *         constants = []
 *         for m from 0 <= m < N:             # <<<<<<<<<<<<<<
 *             constant = False
 *             multiplier = 1
 */
  __pyx_t_31 = __Pyx_PyInt_AsLong(__pyx_v_N); if (unlikely((__pyx_t_31 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32++) {
    __pyx_t_8 = PyInt_FromLong(__pyx_t_32); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_XDECREF(__pyx_v_m);
    __pyx_v_m = __pyx_t_8;
    __pyx_t_8 = 0;

  /* "water_algorithm_cython.pyx":2041
 *         multipliers = []
 *         constants = []
 *         for m from 0 <= m < N:             # <<<<<<<<<<<<<<
 *             constant = False
 *             multiplier = 1
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_t_32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_v_m);
  __pyx_v_m = __pyx_t_1;
  __pyx_t_1 = 0;
 2042:             constant = False
    /* "water_algorithm_cython.pyx":2042
 *         constants = []
 *         for m from 0 <= m < N:
 *             constant = False             # <<<<<<<<<<<<<<
 *             multiplier = 1
 *             for n, index in enumerate(indeces[m]):
 */
    __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_XDECREF(__pyx_v_constant);
    __pyx_v_constant = __pyx_t_8;
    __pyx_t_8 = 0;
 2043:             multiplier = 1
    /* "water_algorithm_cython.pyx":2043
 *         for m from 0 <= m < N:
 *             constant = False
 *             multiplier = 1             # <<<<<<<<<<<<<<
 *             for n, index in enumerate(indeces[m]):
 *                 if index[0] > index[1]:
 */
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_XDECREF(__pyx_v_multiplier);
    __pyx_v_multiplier = __pyx_int_1;
 2044:             for n, index in enumerate(indeces[m]):
    /* "water_algorithm_cython.pyx":2044
 *             constant = False
 *             multiplier = 1
 *             for n, index in enumerate(indeces[m]):             # <<<<<<<<<<<<<<
 *                 if index[0] > index[1]:
 *                     new_index_2 = get_opposite_periodicity_axis_number(index[2])
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_8 = __pyx_int_0;
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), __pyx_v_m); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_29 = __pyx_t_1; __Pyx_INCREF(__pyx_t_29); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_29 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_6 = Py_TYPE(__pyx_t_29)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_29)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_29)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_29, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_29, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_29)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_29)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_29, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_29, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_6(__pyx_t_29);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_index);
      __pyx_v_index = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_v_n);
      __pyx_v_n = __pyx_t_8;
      __pyx_t_1 = PyNumber_Add(__pyx_t_8, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8);
      __pyx_t_8 = __pyx_t_1;
      __pyx_t_1 = 0;
 2045:                 if index[0] > index[1]:
      /* "water_algorithm_cython.pyx":2045
 *             multiplier = 1
 *             for n, index in enumerate(indeces[m]):
 *                 if index[0] > index[1]:             # <<<<<<<<<<<<<<
 *                     new_index_2 = get_opposite_periodicity_axis_number(index[2])
 *                     indeces[m, n] = np.array([index[1], index[0], new_index_2], dtype=DTYPE2)
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_index, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_index, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_26 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_GT); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_26); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      if (__pyx_t_9) {
 2046:                     new_index_2 = get_opposite_periodicity_axis_number(index[2])
        /* "water_algorithm_cython.pyx":2046
 *             for n, index in enumerate(indeces[m]):
 *                 if index[0] > index[1]:
 *                     new_index_2 = get_opposite_periodicity_axis_number(index[2])             # <<<<<<<<<<<<<<
 *                     indeces[m, n] = np.array([index[1], index[0], new_index_2], dtype=DTYPE2)
 *                     multiplier *= -1
 */
        __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_index, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_26);
        __pyx_t_33 = __Pyx_PyInt_from_py_npy_uint8(__pyx_t_26); if (unlikely((__pyx_t_33 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __pyx_v_new_index_2 = __pyx_f_22water_algorithm_cython_get_opposite_periodicity_axis_number(__pyx_t_33);
 2047:                     indeces[m, n] = np.array([index[1], index[0], new_index_2], dtype=DTYPE2)
        /* "water_algorithm_cython.pyx":2047
 *                 if index[0] > index[1]:
 *                     new_index_2 = get_opposite_periodicity_axis_number(index[2])
 *                     indeces[m, n] = np.array([index[1], index[0], new_index_2], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                     multiplier *= -1
 *             multipliers.append(multiplier)
 */
        __pyx_t_26 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_26);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_index, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_26);
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_index, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_27 = __Pyx_PyInt_to_py_npy_uint8(__pyx_v_new_index_2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_27);
        __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_26);
        __Pyx_GIVEREF(__pyx_t_26);
        PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        PyList_SET_ITEM(__pyx_t_3, 2, __pyx_t_27);
        __Pyx_GIVEREF(__pyx_t_27);
        __pyx_t_26 = 0;
        __pyx_t_1 = 0;
        __pyx_t_27 = 0;
        __pyx_t_27 = PyTuple_New(1); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_27);
        PyTuple_SET_ITEM(__pyx_t_27, 0, ((PyObject *)__pyx_t_3));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
        __pyx_t_3 = 0;
        __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_27), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_27)); __pyx_t_27 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_v_n);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_n);
        __Pyx_GIVEREF(__pyx_v_n);
        if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 2048:                     multiplier *= -1
        /* "water_algorithm_cython.pyx":2048
 *                     new_index_2 = get_opposite_periodicity_axis_number(index[2])
 *                     indeces[m, n] = np.array([index[1], index[0], new_index_2], dtype=DTYPE2)
 *                     multiplier *= -1             # <<<<<<<<<<<<<<
 *             multipliers.append(multiplier)
 *             if indeces[m, 0, 0] > indeces[m, 1, 0]:
 */
        __pyx_t_1 = PyNumber_InPlaceMultiply(__pyx_v_multiplier, __pyx_int_neg_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_v_multiplier);
        __pyx_v_multiplier = __pyx_t_1;
        __pyx_t_1 = 0;
        goto __pyx_L16;
      }
      __pyx_L16:;
    }
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 2049:             multipliers.append(multiplier)
    /* "water_algorithm_cython.pyx":2049
 *                     indeces[m, n] = np.array([index[1], index[0], new_index_2], dtype=DTYPE2)
 *                     multiplier *= -1
 *             multipliers.append(multiplier)             # <<<<<<<<<<<<<<
 *             if indeces[m, 0, 0] > indeces[m, 1, 0]:
 *                 indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 */
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_multipliers, __pyx_v_multiplier); if (unlikely(__pyx_t_34 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2050:             if indeces[m, 0, 0] > indeces[m, 1, 0]:
    /* "water_algorithm_cython.pyx":2050
 *                     multiplier *= -1
 *             multipliers.append(multiplier)
 *             if indeces[m, 0, 0] > indeces[m, 1, 0]:             # <<<<<<<<<<<<<<
 *                 indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *             elif indeces[m, 0, 0] == indeces[m, 1, 0]:
 */
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_m);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_m);
    __Pyx_GIVEREF(__pyx_v_m);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __pyx_t_29 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_8)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_m);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_m);
    __Pyx_GIVEREF(__pyx_v_m);
    __Pyx_INCREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_8)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_29, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_9) {
 2051:                 indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
      /* "water_algorithm_cython.pyx":2051
 *             multipliers.append(multiplier)
 *             if indeces[m, 0, 0] > indeces[m, 1, 0]:
 *                 indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *             elif indeces[m, 0, 0] == indeces[m, 1, 0]:
 *                 if indeces[m, 0, 1] > indeces[m, 1, 1]:
 */
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __pyx_t_29 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_8)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_8)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_29 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), __pyx_v_m, __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      goto __pyx_L17;
    }
 2052:             elif indeces[m, 0, 0] == indeces[m, 1, 0]:
    /* "water_algorithm_cython.pyx":2052
 *             if indeces[m, 0, 0] > indeces[m, 1, 0]:
 *                 indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *             elif indeces[m, 0, 0] == indeces[m, 1, 0]:             # <<<<<<<<<<<<<<
 *                 if indeces[m, 0, 1] > indeces[m, 1, 1]:
 *                     indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 */
    __pyx_t_29 = PyTuple_New(3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_INCREF(__pyx_v_m);
    PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_v_m);
    __Pyx_GIVEREF(__pyx_v_m);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_29, 2, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_29)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
    __pyx_t_29 = PyTuple_New(3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_INCREF(__pyx_v_m);
    PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_v_m);
    __Pyx_GIVEREF(__pyx_v_m);
    __Pyx_INCREF(__pyx_int_1);
    PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_29, 2, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_29)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
    __pyx_t_29 = PyObject_RichCompare(__pyx_t_8, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_29); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_29); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    if (__pyx_t_9) {
 2053:                 if indeces[m, 0, 1] > indeces[m, 1, 1]:
      /* "water_algorithm_cython.pyx":2053
 *                 indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *             elif indeces[m, 0, 0] == indeces[m, 1, 0]:
 *                 if indeces[m, 0, 1] > indeces[m, 1, 1]:             # <<<<<<<<<<<<<<
 *                     indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *                 elif indeces[m, 0, 1] == indeces[m, 1, 1]:
 */
      __pyx_t_29 = PyTuple_New(3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_29, 2, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_29)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
      __pyx_t_29 = PyTuple_New(3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_29, 2, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_29)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_RichCompare(__pyx_t_3, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_29); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_29); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      if (__pyx_t_9) {
 2054:                     indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
        /* "water_algorithm_cython.pyx":2054
 *             elif indeces[m, 0, 0] == indeces[m, 1, 0]:
 *                 if indeces[m, 0, 1] > indeces[m, 1, 1]:
 *                     indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                 elif indeces[m, 0, 1] == indeces[m, 1, 1]:
 *                     if indeces[m, 0, 2] > indeces[m, 1, 2]:
 */
        __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_29);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s__array); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_29);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_29)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
        __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_29);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_29)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
        __pyx_t_29 = PyList_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_29);
        PyList_SET_ITEM(__pyx_t_29, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        PyList_SET_ITEM(__pyx_t_29, 1, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_3 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_29));
        __Pyx_GIVEREF(((PyObject *)__pyx_t_29));
        __pyx_t_29 = 0;
        __pyx_t_29 = PyDict_New(); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_29));
        __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        if (PyDict_SetItem(__pyx_t_29, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_29)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
        if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), __pyx_v_m, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L18;
      }
 2055:                 elif indeces[m, 0, 1] == indeces[m, 1, 1]:
      /* "water_algorithm_cython.pyx":2055
 *                 if indeces[m, 0, 1] > indeces[m, 1, 1]:
 *                     indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *                 elif indeces[m, 0, 1] == indeces[m, 1, 1]:             # <<<<<<<<<<<<<<
 *                     if indeces[m, 0, 2] > indeces[m, 1, 2]:
 *                         indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 */
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __pyx_t_29 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_m);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
      __Pyx_GIVEREF(__pyx_v_m);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __Pyx_INCREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_29, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2055; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_9) {
 2056:                     if indeces[m, 0, 2] > indeces[m, 1, 2]:
        /* "water_algorithm_cython.pyx":2056
 *                     indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *                 elif indeces[m, 0, 1] == indeces[m, 1, 1]:
 *                     if indeces[m, 0, 2] > indeces[m, 1, 2]:             # <<<<<<<<<<<<<<
 *                         indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *                     elif indeces[m, 0, 2] == indeces[m, 1, 2]:
 */
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        __Pyx_INCREF(__pyx_int_2);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
        __Pyx_GIVEREF(__pyx_int_2);
        __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        __Pyx_INCREF(__pyx_int_2);
        PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_2);
        __Pyx_GIVEREF(__pyx_int_2);
        __pyx_t_29 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_29);
        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_29, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_9) {
 2057:                         indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
          /* "water_algorithm_cython.pyx":2057
 *                 elif indeces[m, 0, 1] == indeces[m, 1, 1]:
 *                     if indeces[m, 0, 2] > indeces[m, 1, 2]:
 *                         indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *                     elif indeces[m, 0, 2] == indeces[m, 1, 2]:
 *                         constant = True
 */
          __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_29);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_INCREF(__pyx_v_m);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
          __Pyx_GIVEREF(__pyx_v_m);
          __Pyx_INCREF(__pyx_int_1);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
          __Pyx_GIVEREF(__pyx_int_1);
          __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_INCREF(__pyx_v_m);
          PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_m);
          __Pyx_GIVEREF(__pyx_v_m);
          __Pyx_INCREF(__pyx_int_0);
          PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
          __Pyx_GIVEREF(__pyx_int_0);
          __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_3)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_8);
          __pyx_t_1 = 0;
          __pyx_t_8 = 0;
          __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_3));
          __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
          __pyx_t_3 = 0;
          __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
          __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyObject_Call(__pyx_t_29, ((PyObject *)__pyx_t_8), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
          if (PyObject_SetItem(((PyObject *)__pyx_v_indeces), __pyx_v_m, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L19;
        }
 2058:                     elif indeces[m, 0, 2] == indeces[m, 1, 2]:
        /* "water_algorithm_cython.pyx":2058
 *                     if indeces[m, 0, 2] > indeces[m, 1, 2]:
 *                         indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *                     elif indeces[m, 0, 2] == indeces[m, 1, 2]:             # <<<<<<<<<<<<<<
 *                         constant = True
 *             constants.append(constant)
 */
        __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        __Pyx_INCREF(__pyx_int_2);
        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_2);
        __Pyx_GIVEREF(__pyx_int_2);
        __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_1)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_m);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_m);
        __Pyx_GIVEREF(__pyx_v_m);
        __Pyx_INCREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        __Pyx_INCREF(__pyx_int_2);
        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_2);
        __Pyx_GIVEREF(__pyx_int_2);
        __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), ((PyObject *)__pyx_t_1)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_9) {
 2059:                         constant = True
          /* "water_algorithm_cython.pyx":2059
 *                         indeces[m] = np.array([indeces[m, 1], indeces[m, 0]], dtype=DTYPE2)
 *                     elif indeces[m, 0, 2] == indeces[m, 1, 2]:
 *                         constant = True             # <<<<<<<<<<<<<<
 *             constants.append(constant)
 * 
 */
          __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_v_constant);
          __pyx_v_constant = __pyx_t_1;
          __pyx_t_1 = 0;
          goto __pyx_L19;
        }
        __pyx_L19:;
        goto __pyx_L18;
      }
      __pyx_L18:;
      goto __pyx_L17;
    }
    __pyx_L17:;
 2060:             constants.append(constant)
    /* "water_algorithm_cython.pyx":2060
 *                     elif indeces[m, 0, 2] == indeces[m, 1, 2]:
 *                         constant = True
 *             constants.append(constant)             # <<<<<<<<<<<<<<
 * 
 *             order_list.append(indeces[m].flatten())
 */
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_constants, __pyx_v_constant); if (unlikely(__pyx_t_34 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2061: 
 2062:             order_list.append(indeces[m].flatten())
    /* "water_algorithm_cython.pyx":2062
 *             constants.append(constant)
 * 
 *             order_list.append(indeces[m].flatten())             # <<<<<<<<<<<<<<
 *         np_order_list = np.array(order_list, dtype=DTYPE)
 *         l = order_of_invariant -1
 */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), __pyx_v_m); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__flatten); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_order_list, __pyx_t_1); if (unlikely(__pyx_t_34 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_32 = __Pyx_PyInt_AsLong(__pyx_v_m); if (unlikely((__pyx_t_32 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
 2063:         np_order_list = np.array(order_list, dtype=DTYPE)
  /* "water_algorithm_cython.pyx":2063
 * 
 *             order_list.append(indeces[m].flatten())
 *         np_order_list = np.array(order_list, dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         l = order_of_invariant -1
 *         counter = 0
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_order_list));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_order_list));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_order_list));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_29 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_29);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_29) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
  __pyx_t_29 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_29);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_np_order_list = __pyx_t_29;
  __pyx_t_29 = 0;
 2064:         l = order_of_invariant -1
  /* "water_algorithm_cython.pyx":2064
 *             order_list.append(indeces[m].flatten())
 *         np_order_list = np.array(order_list, dtype=DTYPE)
 *         l = order_of_invariant -1             # <<<<<<<<<<<<<<
 *         counter = 0
 *         lists = []
 */
  __pyx_t_29 = PyInt_FromLong((__pyx_v_order_of_invariant - 1)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_29);
  __Pyx_DECREF(__pyx_v_l);
  __pyx_v_l = __pyx_t_29;
  __pyx_t_29 = 0;
 2065:         counter = 0
  /* "water_algorithm_cython.pyx":2065
 *         np_order_list = np.array(order_list, dtype=DTYPE)
 *         l = order_of_invariant -1
 *         counter = 0             # <<<<<<<<<<<<<<
 *         lists = []
 *         while l >= 0:
 */
  __pyx_v_counter = 0;
 2066:         lists = []
  /* "water_algorithm_cython.pyx":2066
 *         l = order_of_invariant -1
 *         counter = 0
 *         lists = []             # <<<<<<<<<<<<<<
 *         while l >= 0:
 *             lists.append(np_order_list[:, l*3+2])
 */
  __pyx_t_29 = PyList_New(0); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_29);
  __pyx_v_lists = ((PyObject*)__pyx_t_29);
  __pyx_t_29 = 0;
 2067:         while l >= 0:
  /* "water_algorithm_cython.pyx":2067
 *         counter = 0
 *         lists = []
 *         while l >= 0:             # <<<<<<<<<<<<<<
 *             lists.append(np_order_list[:, l*3+2])
 *             lists.append(np_order_list[:,  l*3+1])
 */
  while (1) {
    __pyx_t_29 = PyObject_RichCompare(__pyx_v_l, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_29); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_29); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    if (!__pyx_t_9) break;
 2068:             lists.append(np_order_list[:, l*3+2])
    /* "water_algorithm_cython.pyx":2068
 *         lists = []
 *         while l >= 0:
 *             lists.append(np_order_list[:, l*3+2])             # <<<<<<<<<<<<<<
 *             lists.append(np_order_list[:,  l*3+1])
 *             lists.append(np_order_list[:,  l*3+0])
 */
    __pyx_t_29 = PyNumber_Multiply(__pyx_v_l, __pyx_int_3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __pyx_t_3 = PyNumber_Add(__pyx_t_29, __pyx_int_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_INCREF(__pyx_k_slice_156);
    PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_k_slice_156);
    __Pyx_GIVEREF(__pyx_k_slice_156);
    PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetItem(__pyx_v_np_order_list, ((PyObject *)__pyx_t_29)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_lists, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "water_algorithm_cython.pyx":2068
 *         lists = []
 *         while l >= 0:
 *             lists.append(np_order_list[:, l*3+2])             # <<<<<<<<<<<<<<
 *             lists.append(np_order_list[:,  l*3+1])
 *             lists.append(np_order_list[:,  l*3+0])
 */
  __pyx_k_slice_156 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_156)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_156);
  __Pyx_GIVEREF(__pyx_k_slice_156);
 2069:             lists.append(np_order_list[:,  l*3+1])
    /* "water_algorithm_cython.pyx":2069
 *         while l >= 0:
 *             lists.append(np_order_list[:, l*3+2])
 *             lists.append(np_order_list[:,  l*3+1])             # <<<<<<<<<<<<<<
 *             lists.append(np_order_list[:,  l*3+0])
 * 
 */
    __pyx_t_3 = PyNumber_Multiply(__pyx_v_l, __pyx_int_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_29 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_k_slice_157);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_k_slice_157);
    __Pyx_GIVEREF(__pyx_k_slice_157);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_29);
    __Pyx_GIVEREF(__pyx_t_29);
    __pyx_t_29 = 0;
    __pyx_t_29 = PyObject_GetItem(__pyx_v_np_order_list, ((PyObject *)__pyx_t_3)); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_lists, __pyx_t_29); if (unlikely(__pyx_t_34 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;

  /* "water_algorithm_cython.pyx":2069
 *         while l >= 0:
 *             lists.append(np_order_list[:, l*3+2])
 *             lists.append(np_order_list[:,  l*3+1])             # <<<<<<<<<<<<<<
 *             lists.append(np_order_list[:,  l*3+0])
 * 
 */
  __pyx_k_slice_157 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_157)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_157);
  __Pyx_GIVEREF(__pyx_k_slice_157);
 2070:             lists.append(np_order_list[:,  l*3+0])
    /* "water_algorithm_cython.pyx":2070
 *             lists.append(np_order_list[:, l*3+2])
 *             lists.append(np_order_list[:,  l*3+1])
 *             lists.append(np_order_list[:,  l*3+0])             # <<<<<<<<<<<<<<
 * 
 *             l -= 1
 */
    __pyx_t_29 = PyNumber_Multiply(__pyx_v_l, __pyx_int_3); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __pyx_t_3 = PyNumber_Add(__pyx_t_29, __pyx_int_0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __pyx_t_29 = PyTuple_New(2); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_INCREF(__pyx_k_slice_158);
    PyTuple_SET_ITEM(__pyx_t_29, 0, __pyx_k_slice_158);
    __Pyx_GIVEREF(__pyx_k_slice_158);
    PyTuple_SET_ITEM(__pyx_t_29, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetItem(__pyx_v_np_order_list, ((PyObject *)__pyx_t_29)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_lists, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "water_algorithm_cython.pyx":2070
 *             lists.append(np_order_list[:, l*3+2])
 *             lists.append(np_order_list[:,  l*3+1])
 *             lists.append(np_order_list[:,  l*3+0])             # <<<<<<<<<<<<<<
 * 
 *             l -= 1
 */
  __pyx_k_slice_158 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_slice_158)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_158);
  __Pyx_GIVEREF(__pyx_k_slice_158);
 2071: 
 2072:             l -= 1
    /* "water_algorithm_cython.pyx":2072
 *             lists.append(np_order_list[:,  l*3+0])
 * 
 *             l -= 1             # <<<<<<<<<<<<<<
 *             counter += 1
 *         ind = np.lexsort(lists)
 */
    __pyx_t_3 = PyNumber_InPlaceSubtract(__pyx_v_l, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_v_l);
    __pyx_v_l = __pyx_t_3;
    __pyx_t_3 = 0;
 2073:             counter += 1
    /* "water_algorithm_cython.pyx":2073
 * 
 *             l -= 1
 *             counter += 1             # <<<<<<<<<<<<<<
 *         ind = np.lexsort(lists)
 *         previous_term = None
 */
    __pyx_v_counter = (__pyx_v_counter + 1);
  }
 2074:         ind = np.lexsort(lists)
  /* "water_algorithm_cython.pyx":2074
 *             l -= 1
 *             counter += 1
 *         ind = np.lexsort(lists)             # <<<<<<<<<<<<<<
 *         previous_term = None
 *         multiplier = 0
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__lexsort); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_29);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_lists));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_lists));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_lists));
  __pyx_t_1 = PyObject_Call(__pyx_t_29, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_ind = __pyx_t_1;
  __pyx_t_1 = 0;
 2075:         previous_term = None
  /* "water_algorithm_cython.pyx":2075
 *             counter += 1
 *         ind = np.lexsort(lists)
 *         previous_term = None             # <<<<<<<<<<<<<<
 *         multiplier = 0
 *         c = 0
 */
  __Pyx_INCREF(Py_None);
  __pyx_v_previous_term = Py_None;
 2076:         multiplier = 0
  /* "water_algorithm_cython.pyx":2076
 *         ind = np.lexsort(lists)
 *         previous_term = None
 *         multiplier = 0             # <<<<<<<<<<<<<<
 *         c = 0
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_XDECREF(__pyx_v_multiplier);
  __pyx_v_multiplier = __pyx_int_0;
 2077:         c = 0
  /* "water_algorithm_cython.pyx":2077
 *         previous_term = None
 *         multiplier = 0
 *         c = 0             # <<<<<<<<<<<<<<
 * 
 *         bv = get_bond_variables_2(water_orientation, self.nearest_neighbors_nos)
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_c = __pyx_int_0;
 2078: 
 2079:         bv = get_bond_variables_2(water_orientation, self.nearest_neighbors_nos)
  /* "water_algorithm_cython.pyx":2079
 *         c = 0
 * 
 *         bv = get_bond_variables_2(water_orientation, self.nearest_neighbors_nos)             # <<<<<<<<<<<<<<
 *         old_value = 0
 *         old_value_str = ""
 */
  if (!(likely(((__pyx_v_water_orientation) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_water_orientation, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((PyObject *)__pyx_f_22water_algorithm_cython_get_bond_variables_2(((PyArrayObject *)__pyx_v_water_orientation), ((PyArrayObject *)__pyx_t_1))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_bv = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
 2080:         old_value = 0
  /* "water_algorithm_cython.pyx":2080
 * 
 *         bv = get_bond_variables_2(water_orientation, self.nearest_neighbors_nos)
 *         old_value = 0             # <<<<<<<<<<<<<<
 *         old_value_str = ""
 *         for i in ind:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_old_value = __pyx_int_0;
 2081:         old_value_str = ""
  /* "water_algorithm_cython.pyx":2081
 *         bv = get_bond_variables_2(water_orientation, self.nearest_neighbors_nos)
 *         old_value = 0
 *         old_value_str = ""             # <<<<<<<<<<<<<<
 *         for i in ind:
 *             mul = multipliers[i]
 */
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
  __pyx_v_old_value_str = __pyx_kp_s_1;
 2082:         for i in ind:
  /* "water_algorithm_cython.pyx":2082
 *         old_value = 0
 *         old_value_str = ""
 *         for i in ind:             # <<<<<<<<<<<<<<
 *             mul = multipliers[i]
 *             current_term = indeces[i]
 */
  if (PyList_CheckExact(__pyx_v_ind) || PyTuple_CheckExact(__pyx_v_ind)) {
    __pyx_t_3 = __pyx_v_ind; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ind); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_6(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = 0;
 2083:             mul = multipliers[i]
    /* "water_algorithm_cython.pyx":2083
 *         old_value_str = ""
 *         for i in ind:
 *             mul = multipliers[i]             # <<<<<<<<<<<<<<
 *             current_term = indeces[i]
 *             constant = constants[i]
 */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_multipliers), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_mul);
    __pyx_v_mul = __pyx_t_1;
    __pyx_t_1 = 0;
 2084:             current_term = indeces[i]
    /* "water_algorithm_cython.pyx":2084
 *         for i in ind:
 *             mul = multipliers[i]
 *             current_term = indeces[i]             # <<<<<<<<<<<<<<
 *             constant = constants[i]
 *             if not constant:
 */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_indeces), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_current_term);
    __pyx_v_current_term = __pyx_t_1;
    __pyx_t_1 = 0;
 2085:             constant = constants[i]
    /* "water_algorithm_cython.pyx":2085
 *             mul = multipliers[i]
 *             current_term = indeces[i]
 *             constant = constants[i]             # <<<<<<<<<<<<<<
 *             if not constant:
 *                 if previous_term is None:
 */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_constants), __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_constant);
    __pyx_v_constant = __pyx_t_1;
    __pyx_t_1 = 0;
 2086:             if not constant:
    /* "water_algorithm_cython.pyx":2086
 *             current_term = indeces[i]
 *             constant = constants[i]
 *             if not constant:             # <<<<<<<<<<<<<<
 *                 if previous_term is None:
 *                     previous_term = current_term
 */
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_constant); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = (!__pyx_t_9);
    if (__pyx_t_10) {
 2087:                 if previous_term is None:
      /* "water_algorithm_cython.pyx":2087
 *             constant = constants[i]
 *             if not constant:
 *                 if previous_term is None:             # <<<<<<<<<<<<<<
 *                     previous_term = current_term
 *                     multiplier = mul
 */
      __pyx_t_10 = (__pyx_v_previous_term == Py_None);
      if (__pyx_t_10) {
 2088:                     previous_term = current_term
        /* "water_algorithm_cython.pyx":2088
 *             if not constant:
 *                 if previous_term is None:
 *                     previous_term = current_term             # <<<<<<<<<<<<<<
 *                     multiplier = mul
 *                 else:
 */
        __Pyx_INCREF(__pyx_v_current_term);
        __Pyx_DECREF(__pyx_v_previous_term);
        __pyx_v_previous_term = __pyx_v_current_term;
 2089:                     multiplier = mul
        /* "water_algorithm_cython.pyx":2089
 *                 if previous_term is None:
 *                     previous_term = current_term
 *                     multiplier = mul             # <<<<<<<<<<<<<<
 *                 else:
 *                     if np.all(current_term == previous_term):
 */
        __Pyx_INCREF(__pyx_v_mul);
        __Pyx_DECREF(__pyx_v_multiplier);
        __pyx_v_multiplier = __pyx_v_mul;
        goto __pyx_L25;
      }
      /*else*/ {
 2090:                 else:
 2091:                     if np.all(current_term == previous_term):
        /* "water_algorithm_cython.pyx":2091
 *                     multiplier = mul
 *                 else:
 *                     if np.all(current_term == previous_term):             # <<<<<<<<<<<<<<
 *                         multiplier += mul
 *                     else:
 */
        __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__all); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_29);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_RichCompare(__pyx_v_current_term, __pyx_v_previous_term, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;
        __pyx_t_1 = PyObject_Call(__pyx_t_29, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_10) {
 2092:                         multiplier += mul
          /* "water_algorithm_cython.pyx":2092
 *                 else:
 *                     if np.all(current_term == previous_term):
 *                         multiplier += mul             # <<<<<<<<<<<<<<
 *                     else:
 *                         invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 */
          __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_multiplier, __pyx_v_mul); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_v_multiplier);
          __pyx_v_multiplier = __pyx_t_1;
          __pyx_t_1 = 0;
          goto __pyx_L26;
        }
        /*else*/ {
 2093:                     else:
 2094:                         invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
          /* "water_algorithm_cython.pyx":2094
 *                         multiplier += mul
 *                     else:
 *                         invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])             # <<<<<<<<<<<<<<
 *                         old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 *                         if multiplier != 0:
 */
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_29 = __Pyx_GetItemInt(__pyx_t_1, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_29);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_27 = __Pyx_GetItemInt(__pyx_t_1, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_27);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_1, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_28 = __Pyx_GetItemInt(__pyx_t_1, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyTuple_New(7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_v_multiplier);
          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_multiplier);
          __Pyx_GIVEREF(__pyx_v_multiplier);
          PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_8);
          PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_29);
          __Pyx_GIVEREF(__pyx_t_29);
          PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_27);
          __Pyx_GIVEREF(__pyx_t_27);
          PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_26);
          __Pyx_GIVEREF(__pyx_t_26);
          PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_t_28);
          __Pyx_GIVEREF(__pyx_t_28);
          __pyx_t_8 = 0;
          __pyx_t_29 = 0;
          __pyx_t_27 = 0;
          __pyx_t_2 = 0;
          __pyx_t_26 = 0;
          __pyx_t_28 = 0;
          __pyx_t_28 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_159), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_28));
          __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
          __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_invariant_str), ((PyObject *)__pyx_t_28)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_1));
          __Pyx_DECREF(((PyObject *)__pyx_t_28)); __pyx_t_28 = 0;
          __Pyx_DECREF(((PyObject *)__pyx_v_invariant_str));
          __pyx_v_invariant_str = ((PyObject*)__pyx_t_1);
          __pyx_t_1 = 0;
 2095:                         old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
          /* "water_algorithm_cython.pyx":2095
 *                     else:
 *                         invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 *                         old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]             # <<<<<<<<<<<<<<
 *                         if multiplier != 0:
 *                             old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 */
          if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_28 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_28); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
          __pyx_t_28 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_28, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
          __pyx_t_28 = PyObject_GetItem(__pyx_t_1, __pyx_t_26); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_26, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_26 = PyObject_GetItem(__pyx_t_28, __pyx_t_1); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyNumber_Multiply(__pyx_v_multiplier, __pyx_t_26); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __pyx_t_28 = __Pyx_GetItemInt(__pyx_t_26, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_26 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_28); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
          __pyx_t_28 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_28, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
          __pyx_t_28 = PyObject_GetItem(__pyx_t_26, __pyx_t_2); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_2, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyObject_GetItem(__pyx_t_28, __pyx_t_26); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_26 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_old_value, __pyx_t_26); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_DECREF(__pyx_v_old_value);
          __pyx_v_old_value = __pyx_t_2;
          __pyx_t_2 = 0;
 2096:                         if multiplier != 0:
          /* "water_algorithm_cython.pyx":2096
 *                         invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 *                         old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 *                         if multiplier != 0:             # <<<<<<<<<<<<<<
 *                             old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 *                         multiplier = mul
 */
          __pyx_t_2 = PyObject_RichCompare(__pyx_v_multiplier, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_10) {
 2097:                             old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
            /* "water_algorithm_cython.pyx":2097
 *                         old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 *                         if multiplier != 0:
 *                             old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])             # <<<<<<<<<<<<<<
 *                         multiplier = mul
 * 
 */
            if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_26); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_26, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_26 = PyObject_GetItem(__pyx_t_2, __pyx_t_1); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = PyObject_GetItem(__pyx_t_26, __pyx_t_2); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
              PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_26); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_28 = __Pyx_GetItemInt(__pyx_t_26, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_28);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_26 = PyObject_GetItem(__pyx_t_2, __pyx_t_28); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
            __pyx_t_28 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_28);
            __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_28, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
            __pyx_t_28 = PyObject_GetItem(__pyx_t_26, __pyx_t_2); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_28);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_INCREF(__pyx_v_multiplier);
            PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_multiplier);
            __Pyx_GIVEREF(__pyx_v_multiplier);
            PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_28);
            __Pyx_GIVEREF(__pyx_t_28);
            __pyx_t_1 = 0;
            __pyx_t_28 = 0;
            __pyx_t_28 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_160), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_28));
            __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
            __pyx_t_2 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_old_value_str), ((PyObject *)__pyx_t_28)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(((PyObject *)__pyx_t_2));
            __Pyx_DECREF(((PyObject *)__pyx_t_28)); __pyx_t_28 = 0;
            __Pyx_DECREF(((PyObject *)__pyx_v_old_value_str));
            __pyx_v_old_value_str = ((PyObject*)__pyx_t_2);
            __pyx_t_2 = 0;
            goto __pyx_L27;
          }
          __pyx_L27:;
 2098:                         multiplier = mul
          /* "water_algorithm_cython.pyx":2098
 *                         if multiplier != 0:
 *                             old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 *                         multiplier = mul             # <<<<<<<<<<<<<<
 * 
 *                         previous_term = current_term
 */
          __Pyx_INCREF(__pyx_v_mul);
          __Pyx_DECREF(__pyx_v_multiplier);
          __pyx_v_multiplier = __pyx_v_mul;
 2099: 
 2100:                         previous_term = current_term
          /* "water_algorithm_cython.pyx":2100
 *                         multiplier = mul
 * 
 *                         previous_term = current_term             # <<<<<<<<<<<<<<
 *             else:
 *                 #print  "+ %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]} is constant" % (mul, current_term[0][0], current_term[0][1], current_term[0][2], current_term[1][0], current_term[1][1], current_term[1][2])
 */
          __Pyx_INCREF(__pyx_v_current_term);
          __Pyx_DECREF(__pyx_v_previous_term);
          __pyx_v_previous_term = __pyx_v_current_term;
        }
        __pyx_L26:;
      }
      __pyx_L25:;
      goto __pyx_L24;
    }
    /*else*/ {
 2101:             else:
 2102:                 #print  "+ %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]} is constant" % (mul, current_term[0][0], current_term[0][1], current_term[0][2], current_term[1][0], current_term[1][1], current_term[1][2])
 2103:                 c += mul
      /* "water_algorithm_cython.pyx":2103
 *             else:
 *                 #print  "+ %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]} is constant" % (mul, current_term[0][0], current_term[0][1], current_term[0][2], current_term[1][0], current_term[1][1], current_term[1][2])
 *                 c += mul             # <<<<<<<<<<<<<<
 *                 previous_term  = None
 *         if previous_term is not None:
 */
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_c, __pyx_v_mul); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_c);
      __pyx_v_c = __pyx_t_2;
      __pyx_t_2 = 0;
 2104:                 previous_term  = None
      /* "water_algorithm_cython.pyx":2104
 *                 #print  "+ %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]} is constant" % (mul, current_term[0][0], current_term[0][1], current_term[0][2], current_term[1][0], current_term[1][1], current_term[1][2])
 *                 c += mul
 *                 previous_term  = None             # <<<<<<<<<<<<<<
 *         if previous_term is not None:
 *             invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 */
      __Pyx_INCREF(Py_None);
      __Pyx_DECREF(__pyx_v_previous_term);
      __pyx_v_previous_term = Py_None;
    }
    __pyx_L24:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2105:         if previous_term is not None:
  /* "water_algorithm_cython.pyx":2105
 *                 c += mul
 *                 previous_term  = None
 *         if previous_term is not None:             # <<<<<<<<<<<<<<
 *             invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 *             old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 */
  __pyx_t_10 = (__pyx_v_previous_term != Py_None);
  if (__pyx_t_10) {
 2106:             invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
    /* "water_algorithm_cython.pyx":2106
 *                 previous_term  = None
 *         if previous_term is not None:
 *             invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])             # <<<<<<<<<<<<<<
 *             old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 *             if multiplier != 0:
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_28 = __Pyx_GetItemInt(__pyx_t_3, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_28) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_28);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_27 = __Pyx_GetItemInt(__pyx_t_3, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_29 = __Pyx_GetItemInt(__pyx_t_3, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_multiplier);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_multiplier);
    __Pyx_GIVEREF(__pyx_v_multiplier);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_28);
    __Pyx_GIVEREF(__pyx_t_28);
    PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_26);
    __Pyx_GIVEREF(__pyx_t_26);
    PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_27);
    __Pyx_GIVEREF(__pyx_t_27);
    PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_t_29);
    __Pyx_GIVEREF(__pyx_t_29);
    __pyx_t_2 = 0;
    __pyx_t_28 = 0;
    __pyx_t_1 = 0;
    __pyx_t_26 = 0;
    __pyx_t_27 = 0;
    __pyx_t_29 = 0;
    __pyx_t_29 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_159), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_29));
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_invariant_str), ((PyObject *)__pyx_t_29)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_invariant_str));
    __pyx_v_invariant_str = ((PyObject*)__pyx_t_3);
    __pyx_t_3 = 0;
 2107:             old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
    /* "water_algorithm_cython.pyx":2107
 *         if previous_term is not None:
 *             invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 *             old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]             # <<<<<<<<<<<<<<
 *             if multiplier != 0:
 *                 old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 */
    if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_29 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_29); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __pyx_t_29 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __pyx_t_27 = __Pyx_GetItemInt(__pyx_t_29, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __pyx_t_29 = PyObject_GetItem(__pyx_t_3, __pyx_t_27); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __pyx_t_27 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_27, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __pyx_t_27 = PyObject_GetItem(__pyx_t_29, __pyx_t_3); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Multiply(__pyx_v_multiplier, __pyx_t_27); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_27 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __pyx_t_29 = __Pyx_GetItemInt(__pyx_t_27, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __pyx_t_27 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_29); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __pyx_t_29 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_29, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __pyx_t_29 = PyObject_GetItem(__pyx_t_27, __pyx_t_26); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_29);
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
    __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_26);
    __pyx_t_27 = __Pyx_GetItemInt(__pyx_t_26, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
    __pyx_t_26 = PyObject_GetItem(__pyx_t_29, __pyx_t_27); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __pyx_t_27 = PyNumber_Multiply(__pyx_t_3, __pyx_t_26); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_27);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
    __pyx_t_26 = PyNumber_InPlaceAdd(__pyx_v_old_value, __pyx_t_27); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __Pyx_DECREF(__pyx_v_old_value);
    __pyx_v_old_value = __pyx_t_26;
    __pyx_t_26 = 0;
 2108:             if multiplier != 0:
    /* "water_algorithm_cython.pyx":2108
 *             invariant_str += " + %i * b_{%i, %i_[%i]} * b_{%i, %i_[%i]}" % (multiplier, previous_term[0][0], previous_term[0][1], previous_term[0][2], previous_term[1][0], previous_term[1][1], previous_term[1][2])
 *             old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 *             if multiplier != 0:             # <<<<<<<<<<<<<<
 *                 old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 *         if c != 0:
 */
    __pyx_t_26 = PyObject_RichCompare(__pyx_v_multiplier, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_26); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
    if (__pyx_t_10) {
 2109:                 old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
      /* "water_algorithm_cython.pyx":2109
 *             old_value += multiplier * bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]] * bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]]
 *             if multiplier != 0:
 *                 old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])             # <<<<<<<<<<<<<<
 *         if c != 0:
 *             invariant_str += " + %i" % c
 */
      if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_27 = __Pyx_GetItemInt(__pyx_t_26, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_26 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_27); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_27, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = PyObject_GetItem(__pyx_t_26, __pyx_t_3); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_previous_term, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_3, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(__pyx_t_27, __pyx_t_26); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      if (unlikely(((PyObject *)__pyx_v_bv) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_26 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_27 = __Pyx_GetItemInt(__pyx_t_26, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_26 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_bv), __pyx_t_27); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __pyx_t_29 = __Pyx_GetItemInt(__pyx_t_27, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __pyx_t_27 = PyObject_GetItem(__pyx_t_26, __pyx_t_29); if (!__pyx_t_27) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = __Pyx_GetItemInt(__pyx_v_previous_term, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __pyx_t_26 = __Pyx_GetItemInt(__pyx_t_29, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_26) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
      __pyx_t_29 = PyObject_GetItem(__pyx_t_27, __pyx_t_26); if (!__pyx_t_29) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_29);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_26 = PyTuple_New(3); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_INCREF(__pyx_v_multiplier);
      PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_v_multiplier);
      __Pyx_GIVEREF(__pyx_v_multiplier);
      PyTuple_SET_ITEM(__pyx_t_26, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_26, 2, __pyx_t_29);
      __Pyx_GIVEREF(__pyx_t_29);
      __pyx_t_3 = 0;
      __pyx_t_29 = 0;
      __pyx_t_29 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_160), ((PyObject *)__pyx_t_26)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_29));
      __Pyx_DECREF(((PyObject *)__pyx_t_26)); __pyx_t_26 = 0;
      __pyx_t_26 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_old_value_str), ((PyObject *)__pyx_t_29)); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_26));
      __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_v_old_value_str));
      __pyx_v_old_value_str = ((PyObject*)__pyx_t_26);
      __pyx_t_26 = 0;
      goto __pyx_L29;
    }
    __pyx_L29:;
    goto __pyx_L28;
  }
  __pyx_L28:;
 2110:         if c != 0:
  /* "water_algorithm_cython.pyx":2110
 *             if multiplier != 0:
 *                 old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 *         if c != 0:             # <<<<<<<<<<<<<<
 *             invariant_str += " + %i" % c
 *             old_value_str  += " + %i" % c
 */
  __pyx_t_26 = PyObject_RichCompare(__pyx_v_c, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_26); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
  if (__pyx_t_10) {
 2111:             invariant_str += " + %i" % c
    /* "water_algorithm_cython.pyx":2111
 *                 old_value_str += " + %i * %i * %i" % (multiplier, bv[previous_term[0][0]][previous_term[0][1]][previous_term[0][2]], bv[previous_term[1][0]][previous_term[1][1]][previous_term[1][2]])
 *         if c != 0:
 *             invariant_str += " + %i" % c             # <<<<<<<<<<<<<<
 *             old_value_str  += " + %i" % c
 *             old_value += c
 */
    __pyx_t_26 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_161), __pyx_v_c); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_26));
    __pyx_t_29 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_invariant_str), ((PyObject *)__pyx_t_26)); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_29));
    __Pyx_DECREF(((PyObject *)__pyx_t_26)); __pyx_t_26 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_invariant_str));
    __pyx_v_invariant_str = ((PyObject*)__pyx_t_29);
    __pyx_t_29 = 0;
 2112:             old_value_str  += " + %i" % c
    /* "water_algorithm_cython.pyx":2112
 *         if c != 0:
 *             invariant_str += " + %i" % c
 *             old_value_str  += " + %i" % c             # <<<<<<<<<<<<<<
 *             old_value += c
 * 
 */
    __pyx_t_29 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_161), __pyx_v_c); if (unlikely(!__pyx_t_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_29));
    __pyx_t_26 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_old_value_str), ((PyObject *)__pyx_t_29)); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_26));
    __Pyx_DECREF(((PyObject *)__pyx_t_29)); __pyx_t_29 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_old_value_str));
    __pyx_v_old_value_str = ((PyObject*)__pyx_t_26);
    __pyx_t_26 = 0;
 2113:             old_value += c
    /* "water_algorithm_cython.pyx":2113
 *             invariant_str += " + %i" % c
 *             old_value_str  += " + %i" % c
 *             old_value += c             # <<<<<<<<<<<<<<
 * 
 *         print invariant_str
 */
    __pyx_t_26 = PyNumber_InPlaceAdd(__pyx_v_old_value, __pyx_v_c); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_26);
    __Pyx_DECREF(__pyx_v_old_value);
    __pyx_v_old_value = __pyx_t_26;
    __pyx_t_26 = 0;
    goto __pyx_L30;
  }
  __pyx_L30:;
 2114: 
 2115:         print invariant_str
  /* "water_algorithm_cython.pyx":2115
 *             old_value += c
 * 
 *         print invariant_str             # <<<<<<<<<<<<<<
 *         #print value_str
 *         print "Value generated from old bond variables %i " % old_value
 */
  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_invariant_str)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2116:         #print value_str
 2117:         print "Value generated from old bond variables %i " % old_value
  /* "water_algorithm_cython.pyx":2117
 *         print invariant_str
 *         #print value_str
 *         print "Value generated from old bond variables %i " % old_value             # <<<<<<<<<<<<<<
 *         print old_value_str
 *         return value
 */
  __pyx_t_26 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_162), __pyx_v_old_value); if (unlikely(!__pyx_t_26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_26));
  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_26)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_26)); __pyx_t_26 = 0;
 2118:         print old_value_str
  /* "water_algorithm_cython.pyx":2118
 *         #print value_str
 *         print "Value generated from old bond variables %i " % old_value
 *         print old_value_str             # <<<<<<<<<<<<<<
 *         return value
 * 
 */
  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_old_value_str)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2119:         return value
  /* "water_algorithm_cython.pyx":2119
 *         print "Value generated from old bond variables %i " % old_value
 *         print old_value_str
 *         return value             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_value);
  __pyx_r = __pyx_v_value;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1);
  __Pyx_XDECREF(__pyx_t_8);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_19, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_28);
  __Pyx_XDECREF(__pyx_t_29);
  __Pyx_XDECREF(__pyx_t_30);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indeces.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.generate_graph_invariant_value", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indeces.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientation_2.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_symmetry_operation);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables_2, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_water_orientation_2);
  __Pyx_XDECREF(__pyx_v_m);
  __Pyx_XDECREF(__pyx_v_nn);
  __Pyx_XDECREF(__pyx_v_index_j);
  __Pyx_XDECREF(__pyx_v_n);
  __Pyx_XDECREF(__pyx_v_index_l);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_invariant_str);
  __Pyx_XDECREF(__pyx_v_value_str);
  __Pyx_XDECREF((PyObject *)__pyx_v_indeces);
  __Pyx_XDECREF(__pyx_v_current_value);
  __Pyx_XDECREF(__pyx_v_order_list);
  __Pyx_XDECREF(__pyx_v_N);
  __Pyx_XDECREF(__pyx_v_multipliers);
  __Pyx_XDECREF(__pyx_v_constants);
  __Pyx_XDECREF(__pyx_v_constant);
  __Pyx_XDECREF(__pyx_v_multiplier);
  __Pyx_XDECREF(__pyx_v_index);
  __Pyx_XDECREF(__pyx_v_np_order_list);
  __Pyx_XDECREF(__pyx_v_lists);
  __Pyx_XDECREF(__pyx_v_ind);
  __Pyx_XDECREF(__pyx_v_previous_term);
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XDECREF(__pyx_v_bv);
  __Pyx_XDECREF(__pyx_v_old_value);
  __Pyx_XDECREF(__pyx_v_old_value_str);
  __Pyx_XDECREF(__pyx_v_mul);
  __Pyx_XDECREF(__pyx_v_current_term);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_83check_symmetricity(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_83check_symmetricity(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_water_orientation_1 = 0;
  PyObject *__pyx_v_water_orientation_2 = 0;
  PyObject *__pyx_v_symmetry_operation = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_symmetricity (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_orientation_1,&__pyx_n_s__water_orientation_2,&__pyx_n_s__symmetry_operation,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation_1)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation_2)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_symmetricity", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__symmetry_operation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("check_symmetricity", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "check_symmetricity") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_water_orientation_1 = values[0];
    __pyx_v_water_orientation_2 = values[1];
    __pyx_v_symmetry_operation = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("check_symmetricity", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.check_symmetricity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_82check_symmetricity(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), __pyx_v_water_orientation_1, __pyx_v_water_orientation_2, __pyx_v_symmetry_operation);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2120: 
 2121: 
 2122:     def check_symmetricity(self, water_orientation_1, water_orientation_2, symmetry_operation):
/* "water_algorithm_cython.pyx":2122
 * 
 * 
 *     def check_symmetricity(self, water_orientation_1, water_orientation_2, symmetry_operation):             # <<<<<<<<<<<<<<
 *         if self.graph_invariants is None:
 *             self.initialize_symmetry_operations()
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_82check_symmetricity(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientation_1, PyObject *__pyx_v_water_orientation_2, PyObject *__pyx_v_symmetry_operation) {
  __Pyx_memviewslice __pyx_v_bond_variables_1 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_bond_variables_2 = { 0, 0, { 0 }, { 0 }, { 0 } };
  struct __pyx_obj_23graph_invariants_cython_Invariant *__pyx_v_invariant = 0;
  PyObject *__pyx_v_i = NULL;
  char __pyx_v_value_1;
  char __pyx_v_value_2;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_symmetricity", 0);
 2123:         if self.graph_invariants is None:
  /* "water_algorithm_cython.pyx":2123
 * 
 *     def check_symmetricity(self, water_orientation_1, water_orientation_2, symmetry_operation):
 *         if self.graph_invariants is None:             # <<<<<<<<<<<<<<
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 */
  __pyx_t_1 = (__pyx_v_self->graph_invariants == ((PyObject*)Py_None));
  if (__pyx_t_1) {
 2124:             self.initialize_symmetry_operations()
    /* "water_algorithm_cython.pyx":2124
 *     def check_symmetricity(self, water_orientation_1, water_orientation_2, symmetry_operation):
 *         if self.graph_invariants is None:
 *             self.initialize_symmetry_operations()             # <<<<<<<<<<<<<<
 *             self.load_invariants()
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->initialize_symmetry_operations(__pyx_v_self);
 2125:             self.load_invariants()
    /* "water_algorithm_cython.pyx":2125
 *         if self.graph_invariants is None:
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()             # <<<<<<<<<<<<<<
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation_1, self.nearest_neighbors_nos, self.N, bond_variables_1)
 */
    ((struct __pyx_vtabstruct_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self->__pyx_vtab)->load_invariants(__pyx_v_self);
    goto __pyx_L3;
  }
  __pyx_L3:;
 2126:         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
  /* "water_algorithm_cython.pyx":2126
 *             self.initialize_symmetry_operations()
 *             self.load_invariants()
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         get_bond_variables_3(water_orientation_1, self.nearest_neighbors_nos, self.N, bond_variables_1)
 *         get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_4);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_bond_variables_1 = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
  __pyx_t_4 = PyInt_FromLong(__pyx_v_self->N); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_4);
  __Pyx_GIVEREF(__pyx_int_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_2);
  if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_bond_variables_2 = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
 2127:         get_bond_variables_3(water_orientation_1, self.nearest_neighbors_nos, self.N, bond_variables_1)
  /* "water_algorithm_cython.pyx":2127
 *             self.load_invariants()
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation_1, self.nearest_neighbors_nos, self.N, bond_variables_1)             # <<<<<<<<<<<<<<
 *         get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 *         self.print_nearest_neighbors_nos(bond_variables_1)
 */
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_water_orientation_1);
  if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_2);
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_6, __pyx_t_7, __pyx_v_self->N, __pyx_v_bond_variables_1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
 2128:         get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
  /* "water_algorithm_cython.pyx":2128
 *         cdef  DTYPE2_t[:, ::1] bond_variables_1 = np.ndarray((self.N, 4), dtype=DTYPE2), bond_variables_2 = np.ndarray((self.N, 4), dtype=DTYPE2)
 *         get_bond_variables_3(water_orientation_1, self.nearest_neighbors_nos, self.N, bond_variables_1)
 *         get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)             # <<<<<<<<<<<<<<
 *         self.print_nearest_neighbors_nos(bond_variables_1)
 *         self.print_nearest_neighbors_nos(bond_variables_2)
 */
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_v_water_orientation_2);
  if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE_t(__pyx_t_2);
  if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_f_22water_algorithm_cython_get_bond_variables_3(__pyx_t_6, __pyx_t_7, __pyx_v_self->N, __pyx_v_bond_variables_2);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
 2129:         self.print_nearest_neighbors_nos(bond_variables_1)
  /* "water_algorithm_cython.pyx":2129
 *         get_bond_variables_3(water_orientation_1, self.nearest_neighbors_nos, self.N, bond_variables_1)
 *         get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 *         self.print_nearest_neighbors_nos(bond_variables_1)             # <<<<<<<<<<<<<<
 *         self.print_nearest_neighbors_nos(bond_variables_2)
 *         self.print_nearest_neighbors_nos(symmetry_operation = symmetry_operation)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_153); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_bond_variables_1, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2130:         self.print_nearest_neighbors_nos(bond_variables_2)
  /* "water_algorithm_cython.pyx":2130
 *         get_bond_variables_3(water_orientation_2, self.nearest_neighbors_nos, self.N, bond_variables_2)
 *         self.print_nearest_neighbors_nos(bond_variables_1)
 *         self.print_nearest_neighbors_nos(bond_variables_2)             # <<<<<<<<<<<<<<
 *         self.print_nearest_neighbors_nos(symmetry_operation = symmetry_operation)
 *         cdef Invariant invariant
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_153); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_bond_variables_2, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 2131:         self.print_nearest_neighbors_nos(symmetry_operation = symmetry_operation)
  /* "water_algorithm_cython.pyx":2131
 *         self.print_nearest_neighbors_nos(bond_variables_1)
 *         self.print_nearest_neighbors_nos(bond_variables_2)
 *         self.print_nearest_neighbors_nos(symmetry_operation = symmetry_operation)             # <<<<<<<<<<<<<<
 *         cdef Invariant invariant
 *         cdef InvariantTerm invariant_term
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_153); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__symmetry_operation), __pyx_v_symmetry_operation) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2132:         cdef Invariant invariant
 2133:         cdef InvariantTerm invariant_term
 2134:         for i, invariant in enumerate(self.graph_invariants):
  /* "water_algorithm_cython.pyx":2134
 *         cdef Invariant invariant
 *         cdef InvariantTerm invariant_term
 *         for i, invariant in enumerate(self.graph_invariants):             # <<<<<<<<<<<<<<
 *             value_1 = invariant._get_value(bond_variables_1.base)
 *             value_2 = invariant._get_value(bond_variables_2.base)
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_3 = __pyx_int_0;
  __pyx_t_2 = ((PyObject *)__pyx_v_self->graph_invariants); __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
  for (;;) {
    if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_23graph_invariants_cython_Invariant))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF(((PyObject *)__pyx_v_invariant));
    __pyx_v_invariant = ((struct __pyx_obj_23graph_invariants_cython_Invariant *)__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_3;
    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = __pyx_t_4;
    __pyx_t_4 = 0;
 2135:             value_1 = invariant._get_value(bond_variables_1.base)
    /* "water_algorithm_cython.pyx":2135
 *         cdef InvariantTerm invariant_term
 *         for i, invariant in enumerate(self.graph_invariants):
 *             value_1 = invariant._get_value(bond_variables_1.base)             # <<<<<<<<<<<<<<
 *             value_2 = invariant._get_value(bond_variables_2.base)
 *             if value_1 != value_2:
 */
    __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_bond_variables_1, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__base); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_int8_t(__pyx_t_9);
    if (unlikely(!__pyx_t_10.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_value_1 = ((struct __pyx_vtabstruct_23graph_invariants_cython_Invariant *)__pyx_v_invariant->__pyx_vtab)->_get_value(__pyx_v_invariant, __pyx_t_10);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
 2136:             value_2 = invariant._get_value(bond_variables_2.base)
    /* "water_algorithm_cython.pyx":2136
 *         for i, invariant in enumerate(self.graph_invariants):
 *             value_1 = invariant._get_value(bond_variables_1.base)
 *             value_2 = invariant._get_value(bond_variables_2.base)             # <<<<<<<<<<<<<<
 *             if value_1 != value_2:
 *                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 */
    __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_v_bond_variables_2, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s__base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_5numpy_int8_t(__pyx_t_4);
    if (unlikely(!__pyx_t_10.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_value_2 = ((struct __pyx_vtabstruct_23graph_invariants_cython_Invariant *)__pyx_v_invariant->__pyx_vtab)->_get_value(__pyx_v_invariant, __pyx_t_10);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
 2137:             if value_1 != value_2:
    /* "water_algorithm_cython.pyx":2137
 *             value_1 = invariant._get_value(bond_variables_1.base)
 *             value_2 = invariant._get_value(bond_variables_2.base)
 *             if value_1 != value_2:             # <<<<<<<<<<<<<<
 *                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                 print invariant
 */
    __pyx_t_1 = (__pyx_v_value_1 != __pyx_v_value_2);
    if (__pyx_t_1) {
 2138:                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
      /* "water_algorithm_cython.pyx":2138
 *             value_2 = invariant._get_value(bond_variables_2.base)
 *             if value_1 != value_2:
 *                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)             # <<<<<<<<<<<<<<
 *                 print invariant
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 */
      __pyx_t_4 = PyInt_FromLong(__pyx_v_value_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = PyInt_FromLong(__pyx_v_value_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      __pyx_t_4 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_155), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_9)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
 2139:                 print invariant
      /* "water_algorithm_cython.pyx":2139
 *             if value_1 != value_2:
 *                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                 print invariant             # <<<<<<<<<<<<<<
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 */
      if (__Pyx_PrintOne(0, ((PyObject *)__pyx_v_invariant)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2140:                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
      /* "water_algorithm_cython.pyx":2140
 *                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                 print invariant
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])             # <<<<<<<<<<<<<<
 *                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 raw_input()
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_163); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_164)); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);

  /* "water_algorithm_cython.pyx":2140
 *                 print "Invariant %i values differ %i, %i" % (i, value_1, value_2)
 *                 print invariant
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])             # <<<<<<<<<<<<<<
 *                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 raw_input()
 */
  __pyx_k_tuple_164 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_k_tuple_164)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_164);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_164));
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_165)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_tuple_165 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_k_tuple_165)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_165);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_165));
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_166)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
  __pyx_k_tuple_166 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_0); if (unlikely(!__pyx_k_tuple_166)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_166);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_166));
      __pyx_t_13 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_167)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
  __pyx_k_tuple_167 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_k_tuple_167)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_167);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_167));
      __pyx_t_14 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_168)); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
  __pyx_k_tuple_168 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_2); if (unlikely(!__pyx_k_tuple_168)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_168);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_168));
      __pyx_t_15 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_169)); if (!__pyx_t_15) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = PyTuple_New(7); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_INCREF(__pyx_v_water_orientation_1);
      PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_water_orientation_1);
      __Pyx_GIVEREF(__pyx_v_water_orientation_1);
      PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_16, 2, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_16, 3, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_16, 4, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_16, 5, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_16, 6, __pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      __pyx_t_11 = 0;
      __pyx_t_4 = 0;
      __pyx_t_12 = 0;
      __pyx_t_13 = 0;
      __pyx_t_14 = 0;
      __pyx_t_15 = 0;
      __pyx_t_15 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_16), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_16)); __pyx_t_16 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_15) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_k_tuple_169 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_2); if (unlikely(!__pyx_k_tuple_169)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_169);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_169));
 2141:                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
      /* "water_algorithm_cython.pyx":2141
 *                 print invariant
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])             # <<<<<<<<<<<<<<
 *                 raw_input()
 *                 #for invariant_term in invariant.invariant_terms:
 */
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_163); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_170)); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);

  /* "water_algorithm_cython.pyx":2141
 *                 print invariant
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])             # <<<<<<<<<<<<<<
 *                 raw_input()
 *                 #for invariant_term in invariant.invariant_terms:
 */
  __pyx_k_tuple_170 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_k_tuple_170)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_170);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_170));
      __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_171)); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
  __pyx_k_tuple_171 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_k_tuple_171)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_171);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_171));
      __pyx_t_14 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_172)); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
  __pyx_k_tuple_172 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_0); if (unlikely(!__pyx_k_tuple_172)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_172);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_172));
      __pyx_t_13 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_173)); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_13);
  __pyx_k_tuple_173 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_k_tuple_173)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_173);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_173));
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_174)); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
  __pyx_k_tuple_174 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_2); if (unlikely(!__pyx_k_tuple_174)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_174);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_174));
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_invariant->original_indeces), ((PyObject *)__pyx_k_tuple_175)); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_11 = PyTuple_New(7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_v_water_orientation_2);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_water_orientation_2);
      __Pyx_GIVEREF(__pyx_v_water_orientation_2);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_11, 6, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_16 = 0;
      __pyx_t_9 = 0;
      __pyx_t_14 = 0;
      __pyx_t_13 = 0;
      __pyx_t_12 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
      if (__Pyx_PrintOne(0, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_k_tuple_175 = PyTuple_Pack(2, __pyx_int_1, __pyx_int_2); if (unlikely(!__pyx_k_tuple_175)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_175);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_175));
 2142:                 raw_input()
      /* "water_algorithm_cython.pyx":2142
 *                 print self.generate_graph_invariant_value(water_orientation_1, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 print self.generate_graph_invariant_value(water_orientation_2, invariant.original_indeces[0, 0], invariant.original_indeces[0, 1], invariant.original_indeces[1, 0], invariant.original_indeces[1, 1], invariant.original_indeces[0, 2], invariant.original_indeces[1, 2])
 *                 raw_input()             # <<<<<<<<<<<<<<
 *                 #for invariant_term in invariant.invariant_terms:
 *                 #    value_1 = invariant_term.get_value(bond_variables_1)
 */
      __pyx_t_4 = PyObject_Call(__pyx_builtin_raw_input, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2143:                 #for invariant_term in invariant.invariant_terms:
 2144:                 #    value_1 = invariant_term.get_value(bond_variables_1)
 2145:                 #    value_2 = invariant_term.get_value(bond_variables_2)
 2146:                 #    if value_1 != value_2:
 2147:                 #        print "Invariant term (%s) values differ %i, %i" % (invariant_term, value_1, value_2)
 2148: 
 2149:         self.view_result(water_orientation_1)
  /* "water_algorithm_cython.pyx":2149
 *                 #        print "Invariant term (%s) values differ %i, %i" % (invariant_term, value_1, value_2)
 * 
 *         self.view_result(water_orientation_1)             # <<<<<<<<<<<<<<
 *         self.view_result(water_orientation_2)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__view_result); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_water_orientation_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_water_orientation_1);
  __Pyx_GIVEREF(__pyx_v_water_orientation_1);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 2150:         self.view_result(water_orientation_2)
  /* "water_algorithm_cython.pyx":2150
 * 
 *         self.view_result(water_orientation_1)
 *         self.view_result(water_orientation_2)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__view_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_water_orientation_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_water_orientation_2);
  __Pyx_GIVEREF(__pyx_v_water_orientation_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_XDECREF(__pyx_t_9);
  __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.check_symmetricity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables_1, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bond_variables_2, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_invariant);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_85view_result(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_85view_result(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("view_result (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_84view_result(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_water_orientation));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2151: 
 2152: 
 2153:     def view_result(self, water_orientation):
/* "water_algorithm_cython.pyx":2153
 * 
 * 
 *     def view_result(self, water_orientation):             # <<<<<<<<<<<<<<
 *         waters = self.get_atoms(water_orientation)
 *         ase.visualize.view(waters)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_84view_result(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  PyObject *__pyx_v_waters = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("view_result", 0);
 2154:         waters = self.get_atoms(water_orientation)
  /* "water_algorithm_cython.pyx":2154
 * 
 *     def view_result(self, water_orientation):
 *         waters = self.get_atoms(water_orientation)             # <<<<<<<<<<<<<<
 *         ase.visualize.view(waters)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_atoms); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_water_orientation);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_water_orientation);
  __Pyx_GIVEREF(__pyx_v_water_orientation);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_waters = __pyx_t_3;
  __pyx_t_3 = 0;
 2155:         ase.visualize.view(waters)
  /* "water_algorithm_cython.pyx":2155
 *     def view_result(self, water_orientation):
 *         waters = self.get_atoms(water_orientation)
 *         ase.visualize.view(waters)             # <<<<<<<<<<<<<<
 * 
 *     def view_oxygen_raft(self):
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__visualize); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__view); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_waters);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_waters);
  __Pyx_GIVEREF(__pyx_v_waters);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.view_result", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_waters);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_87view_oxygen_raft(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_87view_oxygen_raft(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("view_oxygen_raft (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_86view_oxygen_raft(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2156: 
 2157:     def view_oxygen_raft(self):
/* "water_algorithm_cython.pyx":2157
 *         ase.visualize.view(waters)
 * 
 *     def view_oxygen_raft(self):             # <<<<<<<<<<<<<<
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
 *         ase.visualize.view(oxygens)
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_86view_oxygen_raft(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("view_oxygen_raft", 0);
 2158:         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
  /* "water_algorithm_cython.pyx":2158
 * 
 *     def view_oxygen_raft(self):
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)             # <<<<<<<<<<<<<<
 *         ase.visualize.view(oxygens)
 * 
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_oxygens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->oxygen_coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__cell), __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__periodic), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_oxygens = __pyx_t_4;
  __pyx_t_4 = 0;
 2159:         ase.visualize.view(oxygens)
  /* "water_algorithm_cython.pyx":2159
 *     def view_oxygen_raft(self):
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
 *         ase.visualize.view(oxygens)             # <<<<<<<<<<<<<<
 * 
 *     def get_atoms(self, water_orientation):
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__visualize); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__view); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_oxygens);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_oxygens);
  __Pyx_GIVEREF(__pyx_v_oxygens);
  __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.view_oxygen_raft", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_89get_atoms(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_89get_atoms(PyObject *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_atoms (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_88get_atoms(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self), ((PyObject *)__pyx_v_water_orientation));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2160: 
 2161:     def get_atoms(self, water_orientation):
/* "water_algorithm_cython.pyx":2161
 *         ase.visualize.view(oxygens)
 * 
 *     def get_atoms(self, water_orientation):             # <<<<<<<<<<<<<<
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
 *         hydrogen_positions = []
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_88get_atoms(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self, PyObject *__pyx_v_water_orientation) {
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_v_hydrogen_positions = NULL;
  PyObject *__pyx_v_hydrogens = NULL;
  PyObject *__pyx_v_waters = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_atoms", 0);
 2162:         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
  /* "water_algorithm_cython.pyx":2162
 * 
 *     def get_atoms(self, water_orientation):
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)             # <<<<<<<<<<<<<<
 *         hydrogen_positions = []
 *         hydrogen_positions = self.get_hydrogen_coordinates(self.oxygen_coordinates, water_orientation,  self.nearest_neighbors_nos)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_oxygens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->oxygen_coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__cell), __pyx_v_self->cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__periodic), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_oxygens = __pyx_t_4;
  __pyx_t_4 = 0;
 2163:         hydrogen_positions = []
  /* "water_algorithm_cython.pyx":2163
 *     def get_atoms(self, water_orientation):
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
 *         hydrogen_positions = []             # <<<<<<<<<<<<<<
 *         hydrogen_positions = self.get_hydrogen_coordinates(self.oxygen_coordinates, water_orientation,  self.nearest_neighbors_nos)
 *         hydrogens = get_hydrogens(hydrogen_positions)
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_hydrogen_positions = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 2164:         hydrogen_positions = self.get_hydrogen_coordinates(self.oxygen_coordinates, water_orientation,  self.nearest_neighbors_nos)
  /* "water_algorithm_cython.pyx":2164
 *         oxygens = get_oxygens(self.oxygen_coordinates, cell = self.cell, periodic = self.periodic)
 *         hydrogen_positions = []
 *         hydrogen_positions = self.get_hydrogen_coordinates(self.oxygen_coordinates, water_orientation,  self.nearest_neighbors_nos)             # <<<<<<<<<<<<<<
 *         hydrogens = get_hydrogens(hydrogen_positions)
 *         waters = oxygens.extend(hydrogens)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_176); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_14); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->oxygen_coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  __Pyx_INCREF(__pyx_v_water_orientation);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_water_orientation);
  __Pyx_GIVEREF(__pyx_v_water_orientation);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_hydrogen_positions);
  __pyx_v_hydrogen_positions = __pyx_t_3;
  __pyx_t_3 = 0;
 2165:         hydrogens = get_hydrogens(hydrogen_positions)
  /* "water_algorithm_cython.pyx":2165
 *         hydrogen_positions = []
 *         hydrogen_positions = self.get_hydrogen_coordinates(self.oxygen_coordinates, water_orientation,  self.nearest_neighbors_nos)
 *         hydrogens = get_hydrogens(hydrogen_positions)             # <<<<<<<<<<<<<<
 *         waters = oxygens.extend(hydrogens)
 *         if self.cell != None:
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_hydrogens); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_hydrogen_positions);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_hydrogen_positions);
  __Pyx_GIVEREF(__pyx_v_hydrogen_positions);
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_hydrogens = __pyx_t_4;
  __pyx_t_4 = 0;
 2166:         waters = oxygens.extend(hydrogens)
  /* "water_algorithm_cython.pyx":2166
 *         hydrogen_positions = self.get_hydrogen_coordinates(self.oxygen_coordinates, water_orientation,  self.nearest_neighbors_nos)
 *         hydrogens = get_hydrogens(hydrogen_positions)
 *         waters = oxygens.extend(hydrogens)             # <<<<<<<<<<<<<<
 *         if self.cell != None:
 *             waters.set_cell(self.cell)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__extend); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_hydrogens);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_hydrogens);
  __Pyx_GIVEREF(__pyx_v_hydrogens);
  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_waters = __pyx_t_3;
  __pyx_t_3 = 0;
 2167:         if self.cell != None:
  /* "water_algorithm_cython.pyx":2167
 *         hydrogens = get_hydrogens(hydrogen_positions)
 *         waters = oxygens.extend(hydrogens)
 *         if self.cell != None:             # <<<<<<<<<<<<<<
 *             waters.set_cell(self.cell)
 *         else:
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_self->cell, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_5) {
 2168:             waters.set_cell(self.cell)
    /* "water_algorithm_cython.pyx":2168
 *         waters = oxygens.extend(hydrogens)
 *         if self.cell != None:
 *             waters.set_cell(self.cell)             # <<<<<<<<<<<<<<
 *         else:
 *             waters.center(vacuum=5)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__set_cell); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_self->cell);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->cell);
    __Pyx_GIVEREF(__pyx_v_self->cell);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 2169:         else:
 2170:             waters.center(vacuum=5)
    /* "water_algorithm_cython.pyx":2170
 *             waters.set_cell(self.cell)
 *         else:
 *             waters.center(vacuum=5)             # <<<<<<<<<<<<<<
 *         return waters
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__center); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__vacuum), __pyx_int_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;
 2171:         return waters
  /* "water_algorithm_cython.pyx":2171
 *         else:
 *             waters.center(vacuum=5)
 *         return waters             # <<<<<<<<<<<<<<
 * 
 *     def write_oxygen_raft_to_file(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_waters);
  __pyx_r = __pyx_v_waters;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.get_atoms", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XDECREF(__pyx_v_hydrogen_positions);
  __Pyx_XDECREF(__pyx_v_hydrogens);
  __Pyx_XDECREF(__pyx_v_waters);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_91write_oxygen_raft_to_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_91write_oxygen_raft_to_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_oxygen_raft_to_file (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_90write_oxygen_raft_to_file(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2172: 
 2173:     def write_oxygen_raft_to_file(self):
/* "water_algorithm_cython.pyx":2173
 *         return waters
 * 
 *     def write_oxygen_raft_to_file(self):             # <<<<<<<<<<<<<<
 *         oxygens = get_oxygens(self.oxygen_coordinates)
 *         oxygens.pbc = self.periodic
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_90write_oxygen_raft_to_file(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_oxygen_raft_to_file", 0);
 2174:         oxygens = get_oxygens(self.oxygen_coordinates)
  /* "water_algorithm_cython.pyx":2174
 * 
 *     def write_oxygen_raft_to_file(self):
 *         oxygens = get_oxygens(self.oxygen_coordinates)             # <<<<<<<<<<<<<<
 *         oxygens.pbc = self.periodic
 *         if self.cell != None:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_oxygens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->oxygen_coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->oxygen_coordinates));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_oxygens = __pyx_t_3;
  __pyx_t_3 = 0;
 2175:         oxygens.pbc = self.periodic
  /* "water_algorithm_cython.pyx":2175
 *     def write_oxygen_raft_to_file(self):
 *         oxygens = get_oxygens(self.oxygen_coordinates)
 *         oxygens.pbc = self.periodic             # <<<<<<<<<<<<<<
 *         if self.cell != None:
 *             oxygens.set_cell(self.cell)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__periodic); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_oxygens, __pyx_n_s__pbc, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2176:         if self.cell != None:
  /* "water_algorithm_cython.pyx":2176
 *         oxygens = get_oxygens(self.oxygen_coordinates)
 *         oxygens.pbc = self.periodic
 *         if self.cell != None:             # <<<<<<<<<<<<<<
 *             oxygens.set_cell(self.cell)
 *         else:
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_self->cell, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
 2177:             oxygens.set_cell(self.cell)
    /* "water_algorithm_cython.pyx":2177
 *         oxygens.pbc = self.periodic
 *         if self.cell != None:
 *             oxygens.set_cell(self.cell)             # <<<<<<<<<<<<<<
 *         else:
 *             oxygens.center(vacuum=5)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__set_cell); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_self->cell);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->cell);
    __Pyx_GIVEREF(__pyx_v_self->cell);
    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
 2178:         else:
 2179:             oxygens.center(vacuum=5)
    /* "water_algorithm_cython.pyx":2179
 *             oxygens.set_cell(self.cell)
 *         else:
 *             oxygens.center(vacuum=5)             # <<<<<<<<<<<<<<
 * 
 *         ase.io.write(("%soxygen_raft.traj" % (self.get_folder())), oxygens, format="traj")
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__center); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__vacuum), __pyx_int_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;
 2180: 
 2181:         ase.io.write(("%soxygen_raft.traj" % (self.get_folder())), oxygens, format="traj")
  /* "water_algorithm_cython.pyx":2181
 *             oxygens.center(vacuum=5)
 * 
 *         ase.io.write(("%soxygen_raft.traj" % (self.get_folder())), oxygens, format="traj")             # <<<<<<<<<<<<<<
 * 
 *     def read_oxygen_raft_from_file(self):
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__io); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_177), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_oxygens);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_oxygens);
  __Pyx_GIVEREF(__pyx_v_oxygens);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__format), ((PyObject *)__pyx_n_s__traj)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.write_oxygen_raft_to_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_93read_oxygen_raft_from_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_93read_oxygen_raft_from_file(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_oxygen_raft_from_file (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_92read_oxygen_raft_from_file(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2182: 
 2183:     def read_oxygen_raft_from_file(self):
/* "water_algorithm_cython.pyx":2183
 *         ase.io.write(("%soxygen_raft.traj" % (self.get_folder())), oxygens, format="traj")
 * 
 *     def read_oxygen_raft_from_file(self):             # <<<<<<<<<<<<<<
 *         try:
 *             return ase.io.read(("%soxygen_raft.traj" % (self.get_folder())))
 */

static PyObject *__pyx_pf_22water_algorithm_cython_14WaterAlgorithm_92read_oxygen_raft_from_file(struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *__pyx_v_self) {
  PyObject *__pyx_v_sys = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_oxygen_raft_from_file", 0);
 2184:         try:
  /* "water_algorithm_cython.pyx":2184
 * 
 *     def read_oxygen_raft_from_file(self):
 *         try:             # <<<<<<<<<<<<<<
 *             return ase.io.read(("%soxygen_raft.traj" % (self.get_folder())))
 *         except IOError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {
 2185:             return ase.io.read(("%soxygen_raft.traj" % (self.get_folder())))
      /* "water_algorithm_cython.pyx":2185
 *     def read_oxygen_raft_from_file(self):
 *         try:
 *             return ase.io.read(("%soxygen_raft.traj" % (self.get_folder())))             # <<<<<<<<<<<<<<
 *         except IOError:
 *             import sys
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__io); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__read); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_folder); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_177), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
      __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2185; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __pyx_r = __pyx_t_5;
      __pyx_t_5 = 0;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
 2186:         except IOError:
    /* "water_algorithm_cython.pyx":2186
 *         try:
 *             return ase.io.read(("%soxygen_raft.traj" % (self.get_folder())))
 *         except IOError:             # <<<<<<<<<<<<<<
 *             import sys
 *             sys.exit("Returning to previous execution failed. Please give the folder of the previous execution  with --folder \"FOLDER_NAME\" command or give the new oxygen raft with --oxygen_raft \"FILE_NAME\" command.")
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_IOError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.read_oxygen_raft_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2186; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_4);
 2187:             import sys
      /* "water_algorithm_cython.pyx":2187
 *             return ase.io.read(("%soxygen_raft.traj" % (self.get_folder())))
 *         except IOError:
 *             import sys             # <<<<<<<<<<<<<<
 *             sys.exit("Returning to previous execution failed. Please give the folder of the previous execution  with --folder \"FOLDER_NAME\" command or give the new oxygen raft with --oxygen_raft \"FILE_NAME\" command.")
 * 
 */
      __pyx_t_8 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0, -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2187; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_v_sys = __pyx_t_8;
      __pyx_t_8 = 0;
 2188:             sys.exit("Returning to previous execution failed. Please give the folder of the previous execution  with --folder \"FOLDER_NAME\" command or give the new oxygen raft with --oxygen_raft \"FILE_NAME\" command.")
      /* "water_algorithm_cython.pyx":2188
 *         except IOError:
 *             import sys
 *             sys.exit("Returning to previous execution failed. Please give the folder of the previous execution  with --folder \"FOLDER_NAME\" command or give the new oxygen raft with --oxygen_raft \"FILE_NAME\" command.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_sys, __pyx_n_s__exit); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_179), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L10_try_end:;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("water_algorithm_cython.WaterAlgorithm.read_oxygen_raft_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sys);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_12O_H_distance_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_22water_algorithm_cython_14WaterAlgorithm_12O_H_distance_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_22water_algorithm_cython_14WaterAlgorithm_12O_H_distance___get__(((struct __pyx_obj_22water_algorithm_cython_WaterAlgorithm *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

  /* "water_algorithm_cython.pyx":2188
 *         except IOError:
 *             import sys
 *             sys.exit("Returning to previous execution failed. Please give the folder of the previous execution  with --folder \"FOLDER_NAME\" command or give the new oxygen raft with --oxygen_raft \"FILE_NAME\" command.")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_179 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_178)); if (unlikely(!__pyx_k_tuple_179)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_179);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_179));
 2189: 
 2190: 
 2191: 
 2192: def write_results_to_file(wa, oxygen_positions, results, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
    /* "water_algorithm_cython.pyx":2192
 * 
 * 
 * def write_results_to_file(wa, oxygen_positions, results, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):             # <<<<<<<<<<<<<<
 *     for i, water_orientation in enumerate(results):
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 */
    values[7] = ((PyObject *)Py_None);
    values[8] = __pyx_k_181;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wa)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__oxygen_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_results_to_file", 0, 5, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__results)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_results_to_file", 0, 5, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_results_to_file", 0, 5, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_14)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_results_to_file", 0, 5, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__folder);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__additional_atoms);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vacuum);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_results_to_file") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_wa = values[0];
    __pyx_v_oxygen_positions = values[1];
    __pyx_v_results = values[2];
    __pyx_v_cell = values[3];
    __pyx_v_nearest_neighbors_nos = values[4];
    __pyx_v_folder = values[5];
    __pyx_v_periodic = values[6];
    __pyx_v_additional_atoms = values[7];
    __pyx_v_vacuum = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_results_to_file", 0, 5, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.write_results_to_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_write_results_to_file(__pyx_self, __pyx_v_wa, __pyx_v_oxygen_positions, __pyx_v_results, __pyx_v_cell, __pyx_v_nearest_neighbors_nos, __pyx_v_folder, __pyx_v_periodic, __pyx_v_additional_atoms, __pyx_v_vacuum);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_write_results_to_file(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_wa, PyObject *__pyx_v_oxygen_positions, PyObject *__pyx_v_results, PyObject *__pyx_v_cell, PyObject *__pyx_v_nearest_neighbors_nos, PyObject *__pyx_v_folder, PyObject *__pyx_v_periodic, PyObject *__pyx_v_additional_atoms, PyObject *__pyx_v_vacuum) {
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_water_orientation = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_results_to_file", 0);

  /* "water_algorithm_cython.pyx":2192
 * 
 * 
 * def write_results_to_file(wa, oxygen_positions, results, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):             # <<<<<<<<<<<<<<
 *     for i, water_orientation in enumerate(results):
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_180 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(5.0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_181 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "water_algorithm_cython.pyx":2192
 * 
 * 
 * def write_results_to_file(wa, oxygen_positions, results, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):             # <<<<<<<<<<<<<<
 *     for i, water_orientation in enumerate(results):
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 */
  __pyx_k_tuple_243 = PyTuple_Pack(11, ((PyObject *)__pyx_n_s__wa), ((PyObject *)__pyx_n_s__oxygen_positions), ((PyObject *)__pyx_n_s__results), ((PyObject *)__pyx_n_s__cell), ((PyObject *)__pyx_n_s_14), ((PyObject *)__pyx_n_s__folder), ((PyObject *)__pyx_n_s__periodic), ((PyObject *)__pyx_n_s__additional_atoms), ((PyObject *)__pyx_n_s__vacuum), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__water_orientation)); if (unlikely(!__pyx_k_tuple_243)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_243);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_243));
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_1write_results_to_file, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_46, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_244 = (PyObject*)__Pyx_PyCode_New(9, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_243, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s_46, 2192, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_244)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2193:     for i, water_orientation in enumerate(results):
  /* "water_algorithm_cython.pyx":2193
 * 
 * def write_results_to_file(wa, oxygen_positions, results, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
 *     for i, water_orientation in enumerate(results):             # <<<<<<<<<<<<<<
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (PyList_CheckExact(__pyx_v_results) || PyTuple_CheckExact(__pyx_v_results)) {
    __pyx_t_2 = __pyx_v_results; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_results); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_5 = __pyx_t_4(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF(__pyx_v_water_orientation);
    __pyx_v_water_orientation = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;
 2194:         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
    /* "water_algorithm_cython.pyx":2194
 * def write_results_to_file(wa, oxygen_positions, results, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
 *     for i, water_orientation in enumerate(results):
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)             # <<<<<<<<<<<<<<
 * 
 * def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_51); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_wa);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_wa);
    __Pyx_GIVEREF(__pyx_v_wa);
    __Pyx_INCREF(__pyx_v_oxygen_positions);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_oxygen_positions);
    __Pyx_GIVEREF(__pyx_v_oxygen_positions);
    __Pyx_INCREF(__pyx_v_water_orientation);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_water_orientation);
    __Pyx_GIVEREF(__pyx_v_water_orientation);
    __Pyx_INCREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    __Pyx_INCREF(__pyx_v_cell);
    PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_cell);
    __Pyx_GIVEREF(__pyx_v_cell);
    __Pyx_INCREF(__pyx_v_nearest_neighbors_nos);
    PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_v_nearest_neighbors_nos);
    __Pyx_GIVEREF(__pyx_v_nearest_neighbors_nos);
    __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
    if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__folder), __pyx_v_folder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__periodic), __pyx_v_periodic) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__additional_atoms), __pyx_v_additional_atoms) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__vacuum), __pyx_v_vacuum) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("water_algorithm_cython.write_results_to_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_water_orientation);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_3write_result_to_file(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_22water_algorithm_cython_3write_result_to_file = {__Pyx_NAMESTR("write_result_to_file"), (PyCFunction)__pyx_pw_22water_algorithm_cython_3write_result_to_file, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_22water_algorithm_cython_3write_result_to_file(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_wa = 0;
  PyObject *__pyx_v_oxygen_positions = 0;
  PyObject *__pyx_v_water_orientation = 0;
  PyObject *__pyx_v_i = 0;
  PyObject *__pyx_v_cell = 0;
  PyObject *__pyx_v_nearest_neighbors_nos = 0;
  PyObject *__pyx_v_folder = 0;
  PyObject *__pyx_v_periodic = 0;
  PyObject *__pyx_v_additional_atoms = 0;
  PyObject *__pyx_v_vacuum = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_result_to_file (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__wa,&__pyx_n_s__oxygen_positions,&__pyx_n_s__water_orientation,&__pyx_n_s__i,&__pyx_n_s__cell,&__pyx_n_s_14,&__pyx_n_s__folder,&__pyx_n_s__periodic,&__pyx_n_s__additional_atoms,&__pyx_n_s__vacuum,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    values[6] = ((PyObject *)__pyx_kp_s_1);
    values[7] = __pyx_k_182;
 2195: 
 2196: def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
    /* "water_algorithm_cython.pyx":2196
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 * 
 * def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):             # <<<<<<<<<<<<<<
 *     oxygens = get_oxygens(oxygen_positions)
 *     hydrogen_positions = []
 */
    values[8] = ((PyObject *)Py_None);
    values[9] = __pyx_k_183;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wa)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__oxygen_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_result_to_file", 0, 6, 10, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_orientation)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_result_to_file", 0, 6, 10, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_result_to_file", 0, 6, 10, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_result_to_file", 0, 6, 10, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_14)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_result_to_file", 0, 6, 10, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__folder);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__additional_atoms);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vacuum);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_result_to_file") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_wa = values[0];
    __pyx_v_oxygen_positions = values[1];
    __pyx_v_water_orientation = values[2];
    __pyx_v_i = values[3];
    __pyx_v_cell = values[4];
    __pyx_v_nearest_neighbors_nos = values[5];
    __pyx_v_folder = values[6];
    __pyx_v_periodic = values[7];
    __pyx_v_additional_atoms = values[8];
    __pyx_v_vacuum = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_result_to_file", 0, 6, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.write_result_to_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_2write_result_to_file(__pyx_self, __pyx_v_wa, __pyx_v_oxygen_positions, __pyx_v_water_orientation, __pyx_v_i, __pyx_v_cell, __pyx_v_nearest_neighbors_nos, __pyx_v_folder, __pyx_v_periodic, __pyx_v_additional_atoms, __pyx_v_vacuum);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_2write_result_to_file(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_wa, PyObject *__pyx_v_oxygen_positions, PyObject *__pyx_v_water_orientation, PyObject *__pyx_v_i, PyObject *__pyx_v_cell, PyObject *__pyx_v_nearest_neighbors_nos, PyObject *__pyx_v_folder, PyObject *__pyx_v_periodic, PyObject *__pyx_v_additional_atoms, PyObject *__pyx_v_vacuum) {
  PyObject *__pyx_v_oxygens = NULL;
  PyObject *__pyx_v_hydrogen_positions = NULL;
  PyObject *__pyx_v_hydrogens = NULL;
  PyObject *__pyx_v_waters = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_xyz = NULL;
  PyObject *__pyx_v_periodic_on_axis = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_result_to_file", 0);
  __Pyx_INCREF(__pyx_v_i);

  /* "water_algorithm_cython.pyx":2196
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 * 
 * def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):             # <<<<<<<<<<<<<<
 *     oxygens = get_oxygens(oxygen_positions)
 *     hydrogen_positions = []
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_182 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(5.0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_183 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "water_algorithm_cython.pyx":2196
 *         write_result_to_file(wa, oxygen_positions, water_orientation, i, cell, nearest_neighbors_nos, folder=folder, periodic=periodic, additional_atoms = additional_atoms, vacuum = vacuum)
 * 
 * def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):             # <<<<<<<<<<<<<<
 *     oxygens = get_oxygens(oxygen_positions)
 *     hydrogen_positions = []
 */
  __pyx_k_tuple_247 = PyTuple_Pack(16, ((PyObject *)__pyx_n_s__wa), ((PyObject *)__pyx_n_s__oxygen_positions), ((PyObject *)__pyx_n_s__water_orientation), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__cell), ((PyObject *)__pyx_n_s_14), ((PyObject *)__pyx_n_s__folder), ((PyObject *)__pyx_n_s__periodic), ((PyObject *)__pyx_n_s__additional_atoms), ((PyObject *)__pyx_n_s__vacuum), ((PyObject *)__pyx_n_s__oxygens), ((PyObject *)__pyx_n_s__hydrogen_positions), ((PyObject *)__pyx_n_s__hydrogens), ((PyObject *)__pyx_n_s__waters), ((PyObject *)__pyx_n_s__xyz), ((PyObject *)__pyx_n_s__periodic_on_axis)); if (unlikely(!__pyx_k_tuple_247)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_247);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_247));
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_3write_result_to_file, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_51, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_248 = (PyObject*)__Pyx_PyCode_New(10, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_247, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s_51, 2196, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_248)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2197:     oxygens = get_oxygens(oxygen_positions)
  /* "water_algorithm_cython.pyx":2197
 * 
 * def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
 *     oxygens = get_oxygens(oxygen_positions)             # <<<<<<<<<<<<<<
 *     hydrogen_positions = []
 *     hydrogen_positions = wa.get_hydrogen_coordinates(oxygen_positions, water_orientation,  nearest_neighbors_nos)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_oxygens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_oxygen_positions);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_oxygen_positions);
  __Pyx_GIVEREF(__pyx_v_oxygen_positions);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_oxygens = __pyx_t_3;
  __pyx_t_3 = 0;
 2198:     hydrogen_positions = []
  /* "water_algorithm_cython.pyx":2198
 * def write_result_to_file(wa, oxygen_positions, water_orientation, i, cell,  nearest_neighbors_nos,  folder='', periodic=False, additional_atoms = None, vacuum = 5.0):
 *     oxygens = get_oxygens(oxygen_positions)
 *     hydrogen_positions = []             # <<<<<<<<<<<<<<
 *     hydrogen_positions = wa.get_hydrogen_coordinates(oxygen_positions, water_orientation,  nearest_neighbors_nos)
 *     hydrogens = get_hydrogens(hydrogen_positions)
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_hydrogen_positions = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
 2199:     hydrogen_positions = wa.get_hydrogen_coordinates(oxygen_positions, water_orientation,  nearest_neighbors_nos)
  /* "water_algorithm_cython.pyx":2199
 *     oxygens = get_oxygens(oxygen_positions)
 *     hydrogen_positions = []
 *     hydrogen_positions = wa.get_hydrogen_coordinates(oxygen_positions, water_orientation,  nearest_neighbors_nos)             # <<<<<<<<<<<<<<
 *     hydrogens = get_hydrogens(hydrogen_positions)
 *     waters = oxygens.extend(hydrogens)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_wa, __pyx_n_s_176); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_oxygen_positions);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_oxygen_positions);
  __Pyx_GIVEREF(__pyx_v_oxygen_positions);
  __Pyx_INCREF(__pyx_v_water_orientation);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_water_orientation);
  __Pyx_GIVEREF(__pyx_v_water_orientation);
  __Pyx_INCREF(__pyx_v_nearest_neighbors_nos);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_nearest_neighbors_nos);
  __Pyx_GIVEREF(__pyx_v_nearest_neighbors_nos);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_hydrogen_positions);
  __pyx_v_hydrogen_positions = __pyx_t_1;
  __pyx_t_1 = 0;
 2200:     hydrogens = get_hydrogens(hydrogen_positions)
  /* "water_algorithm_cython.pyx":2200
 *     hydrogen_positions = []
 *     hydrogen_positions = wa.get_hydrogen_coordinates(oxygen_positions, water_orientation,  nearest_neighbors_nos)
 *     hydrogens = get_hydrogens(hydrogen_positions)             # <<<<<<<<<<<<<<
 *     waters = oxygens.extend(hydrogens)
 *     if additional_atoms != None:
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_hydrogens); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_hydrogen_positions);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_hydrogen_positions);
  __Pyx_GIVEREF(__pyx_v_hydrogen_positions);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_hydrogens = __pyx_t_3;
  __pyx_t_3 = 0;
 2201:     waters = oxygens.extend(hydrogens)
  /* "water_algorithm_cython.pyx":2201
 *     hydrogen_positions = wa.get_hydrogen_coordinates(oxygen_positions, water_orientation,  nearest_neighbors_nos)
 *     hydrogens = get_hydrogens(hydrogen_positions)
 *     waters = oxygens.extend(hydrogens)             # <<<<<<<<<<<<<<
 *     if additional_atoms != None:
 *         waters = waters.extend(additional_atoms)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_oxygens, __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_hydrogens);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_hydrogens);
  __Pyx_GIVEREF(__pyx_v_hydrogens);
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_waters = __pyx_t_1;
  __pyx_t_1 = 0;
 2202:     if additional_atoms != None:
  /* "water_algorithm_cython.pyx":2202
 *     hydrogens = get_hydrogens(hydrogen_positions)
 *     waters = oxygens.extend(hydrogens)
 *     if additional_atoms != None:             # <<<<<<<<<<<<<<
 *         waters = waters.extend(additional_atoms)
 *     waters.set_positions(waters.get_positions())
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_additional_atoms, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {
 2203:         waters = waters.extend(additional_atoms)
    /* "water_algorithm_cython.pyx":2203
 *     waters = oxygens.extend(hydrogens)
 *     if additional_atoms != None:
 *         waters = waters.extend(additional_atoms)             # <<<<<<<<<<<<<<
 *     waters.set_positions(waters.get_positions())
 *     waters.pbc = periodic
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_additional_atoms);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_additional_atoms);
    __Pyx_GIVEREF(__pyx_v_additional_atoms);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_waters);
    __pyx_v_waters = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 2204:     waters.set_positions(waters.get_positions())
  /* "water_algorithm_cython.pyx":2204
 *     if additional_atoms != None:
 *         waters = waters.extend(additional_atoms)
 *     waters.set_positions(waters.get_positions())             # <<<<<<<<<<<<<<
 *     waters.pbc = periodic
 *     if cell is not None:
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__set_positions); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__get_positions); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 2205:     waters.pbc = periodic
  /* "water_algorithm_cython.pyx":2205
 *         waters = waters.extend(additional_atoms)
 *     waters.set_positions(waters.get_positions())
 *     waters.pbc = periodic             # <<<<<<<<<<<<<<
 *     if cell is not None:
 *         waters.set_cell(cell)
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_waters, __pyx_n_s__pbc, __pyx_v_periodic) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2206:     if cell is not None:
  /* "water_algorithm_cython.pyx":2206
 *     waters.set_positions(waters.get_positions())
 *     waters.pbc = periodic
 *     if cell is not None:             # <<<<<<<<<<<<<<
 *         waters.set_cell(cell)
 *     else:
 */
  __pyx_t_4 = (__pyx_v_cell != Py_None);
  if (__pyx_t_4) {
 2207:         waters.set_cell(cell)
    /* "water_algorithm_cython.pyx":2207
 *     waters.pbc = periodic
 *     if cell is not None:
 *         waters.set_cell(cell)             # <<<<<<<<<<<<<<
 *     else:
 *         if additional_atoms is not None:
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__set_cell); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_cell);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_cell);
    __Pyx_GIVEREF(__pyx_v_cell);
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  /*else*/ {
 2208:     else:
 2209:         if additional_atoms is not None:
    /* "water_algorithm_cython.pyx":2209
 *         waters.set_cell(cell)
 *     else:
 *         if additional_atoms is not None:             # <<<<<<<<<<<<<<
 *             waters.set_cell(additional_atoms.get_cell())
 *     if periodic is None or ( type(periodic) == bool and not periodic ):
 */
    __pyx_t_4 = (__pyx_v_additional_atoms != Py_None);
    if (__pyx_t_4) {
 2210:             waters.set_cell(additional_atoms.get_cell())
      /* "water_algorithm_cython.pyx":2210
 *     else:
 *         if additional_atoms is not None:
 *             waters.set_cell(additional_atoms.get_cell())             # <<<<<<<<<<<<<<
 *     if periodic is None or ( type(periodic) == bool and not periodic ):
 *         waters.center(vacuum=vacuum)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__set_cell); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_additional_atoms, __pyx_n_s__get_cell); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __pyx_L4:;
 2211:     if periodic is None or ( type(periodic) == bool and not periodic ):
  /* "water_algorithm_cython.pyx":2211
 *         if additional_atoms is not None:
 *             waters.set_cell(additional_atoms.get_cell())
 *     if periodic is None or ( type(periodic) == bool and not periodic ):             # <<<<<<<<<<<<<<
 *         waters.center(vacuum=vacuum)
 *     elif type(periodic) == list or type(periodic) == np.ndarray:
 */
  __pyx_t_4 = (__pyx_v_periodic == Py_None);
  if (!__pyx_t_4) {
    __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_periodic)), ((PyObject *)((PyObject*)__pyx_ptype_7cpython_4bool_bool)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_5) {
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_periodic); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_7 = (!__pyx_t_6);
      __pyx_t_6 = __pyx_t_7;
    } else {
      __pyx_t_6 = __pyx_t_5;
    }
    __pyx_t_5 = __pyx_t_6;
  } else {
    __pyx_t_5 = __pyx_t_4;
  }
  if (__pyx_t_5) {
 2212:         waters.center(vacuum=vacuum)
    /* "water_algorithm_cython.pyx":2212
 *             waters.set_cell(additional_atoms.get_cell())
 *     if periodic is None or ( type(periodic) == bool and not periodic ):
 *         waters.center(vacuum=vacuum)             # <<<<<<<<<<<<<<
 *     elif type(periodic) == list or type(periodic) == np.ndarray:
 *         xyz = "xyz"
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__center); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__vacuum), __pyx_v_vacuum) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L6;
  }
 2213:     elif type(periodic) == list or type(periodic) == np.ndarray:
  /* "water_algorithm_cython.pyx":2213
 *     if periodic is None or ( type(periodic) == bool and not periodic ):
 *         waters.center(vacuum=vacuum)
 *     elif type(periodic) == list or type(periodic) == np.ndarray:             # <<<<<<<<<<<<<<
 *         xyz = "xyz"
 *         for i, periodic_on_axis in enumerate(periodic):
 */
  __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_periodic)), ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_5) {
    __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_periodic)), ((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __pyx_t_4;
  } else {
    __pyx_t_6 = __pyx_t_5;
  }
  if (__pyx_t_6) {
 2214:         xyz = "xyz"
    /* "water_algorithm_cython.pyx":2214
 *         waters.center(vacuum=vacuum)
 *     elif type(periodic) == list or type(periodic) == np.ndarray:
 *         xyz = "xyz"             # <<<<<<<<<<<<<<
 *         for i, periodic_on_axis in enumerate(periodic):
 *             if not periodic_on_axis:
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__xyz));
    __pyx_v_xyz = __pyx_n_s__xyz;
 2215:         for i, periodic_on_axis in enumerate(periodic):
    /* "water_algorithm_cython.pyx":2215
 *     elif type(periodic) == list or type(periodic) == np.ndarray:
 *         xyz = "xyz"
 *         for i, periodic_on_axis in enumerate(periodic):             # <<<<<<<<<<<<<<
 *             if not periodic_on_axis:
 *                 waters.center(vacuum = vacuum, axis = i)
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_3 = __pyx_int_0;
    if (PyList_CheckExact(__pyx_v_periodic) || PyTuple_CheckExact(__pyx_v_periodic)) {
      __pyx_t_2 = __pyx_v_periodic; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
    } else {
      __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_periodic); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_9(__pyx_t_2);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_XDECREF(__pyx_v_periodic_on_axis);
      __pyx_v_periodic_on_axis = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_3;
      __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3);
      __pyx_t_3 = __pyx_t_1;
      __pyx_t_1 = 0;
 2216:             if not periodic_on_axis:
      /* "water_algorithm_cython.pyx":2216
 *         xyz = "xyz"
 *         for i, periodic_on_axis in enumerate(periodic):
 *             if not periodic_on_axis:             # <<<<<<<<<<<<<<
 *                 waters.center(vacuum = vacuum, axis = i)
 *     ase.io.write(("%sWater_structure_%i.traj" % (folder,  i)), waters, format="traj")
 */
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_periodic_on_axis); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = (!__pyx_t_6);
      if (__pyx_t_5) {
 2217:                 waters.center(vacuum = vacuum, axis = i)
        /* "water_algorithm_cython.pyx":2217
 *         for i, periodic_on_axis in enumerate(periodic):
 *             if not periodic_on_axis:
 *                 waters.center(vacuum = vacuum, axis = i)             # <<<<<<<<<<<<<<
 *     ase.io.write(("%sWater_structure_%i.traj" % (folder,  i)), waters, format="traj")
 * 
 */
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_waters, __pyx_n_s__center); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_10));
        if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__vacuum), __pyx_v_vacuum) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__axis), __pyx_v_i) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L9;
      }
      __pyx_L9:;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;
 2218:     ase.io.write(("%sWater_structure_%i.traj" % (folder,  i)), waters, format="traj")
  /* "water_algorithm_cython.pyx":2218
 *             if not periodic_on_axis:
 *                 waters.center(vacuum = vacuum, axis = i)
 *     ase.io.write(("%sWater_structure_%i.traj" % (folder,  i)), waters, format="traj")             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__ase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__io); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_folder);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_folder);
  __Pyx_GIVEREF(__pyx_v_folder);
  __Pyx_INCREF(__pyx_v_i);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_i);
  __Pyx_GIVEREF(__pyx_v_i);
  __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_184), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_11));
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_11));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_11));
  __Pyx_INCREF(__pyx_v_waters);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_waters);
  __Pyx_GIVEREF(__pyx_v_waters);
  __pyx_t_11 = 0;
  __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_11));
  if (PyDict_SetItem(__pyx_t_11, ((PyObject *)__pyx_n_s__format), ((PyObject *)__pyx_n_s__traj)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("water_algorithm_cython.write_result_to_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_oxygens);
  __Pyx_XDECREF(__pyx_v_hydrogen_positions);
  __Pyx_XDECREF(__pyx_v_hydrogens);
  __Pyx_XDECREF(__pyx_v_waters);
  __Pyx_XDECREF(__pyx_v_xyz);
  __Pyx_XDECREF(__pyx_v_periodic_on_axis);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_5find_hydrogen_bonds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_22water_algorithm_cython_5find_hydrogen_bonds = {__Pyx_NAMESTR("find_hydrogen_bonds"), (PyCFunction)__pyx_pw_22water_algorithm_cython_5find_hydrogen_bonds, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_22water_algorithm_cython_5find_hydrogen_bonds(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_atom_position = 0;
  PyObject *__pyx_v_atom_positions = 0;
  PyObject *__pyx_v_periodic = 0;
  PyObject *__pyx_v_cell = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("find_hydrogen_bonds (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__atom_position,&__pyx_n_s__atom_positions,&__pyx_n_s__periodic,&__pyx_n_s__cell,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_k_185;
 2219: 
 2220: 
 2221: 
 2222: def find_hydrogen_bonds(atom_position, atom_positions, periodic=False, cell=None):
    /* "water_algorithm_cython.pyx":2222
 * 
 * 
 * def find_hydrogen_bonds(atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.array([])
 *     periodicity = []
 */
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_position)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("find_hydrogen_bonds", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "find_hydrogen_bonds") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_atom_position = values[0];
    __pyx_v_atom_positions = values[1];
    __pyx_v_periodic = values[2];
    __pyx_v_cell = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("find_hydrogen_bonds", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.find_hydrogen_bonds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_4find_hydrogen_bonds(__pyx_self, __pyx_v_atom_position, __pyx_v_atom_positions, __pyx_v_periodic, __pyx_v_cell);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_4find_hydrogen_bonds(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_atom_position, PyObject *__pyx_v_atom_positions, PyObject *__pyx_v_periodic, PyObject *__pyx_v_cell) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_periodicity = NULL;
  long __pyx_v_count;
  CYTHON_UNUSED long __pyx_v_periodic_count;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_distance = NULL;
  PyObject *__pyx_v_periodic_distance = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_real_position = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("find_hydrogen_bonds", 0);

  /* "water_algorithm_cython.pyx":2222
 * 
 * 
 * def find_hydrogen_bonds(atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.array([])
 *     periodicity = []
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_185 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "water_algorithm_cython.pyx":2222
 * 
 * 
 * def find_hydrogen_bonds(atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.array([])
 *     periodicity = []
 */
  __pyx_k_tuple_249 = PyTuple_Pack(12, ((PyObject *)__pyx_n_s__atom_position), ((PyObject *)__pyx_n_s__atom_positions), ((PyObject *)__pyx_n_s__periodic), ((PyObject *)__pyx_n_s__cell), ((PyObject *)__pyx_n_s__result), ((PyObject *)__pyx_n_s__periodicity), ((PyObject *)__pyx_n_s__count), ((PyObject *)__pyx_n_s__periodic_count), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__distance), ((PyObject *)__pyx_n_s__periodic_distance), ((PyObject *)__pyx_n_s__real_position)); if (unlikely(!__pyx_k_tuple_249)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_249);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_249));
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_5find_hydrogen_bonds, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__find_hydrogen_bonds, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_250 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_249, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s__find_hydrogen_bonds, 2222, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_250)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2223:     result = np.array([])
  /* "water_algorithm_cython.pyx":2223
 * 
 * def find_hydrogen_bonds(atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.array([])             # <<<<<<<<<<<<<<
 *     periodicity = []
 *     count = 0
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;
 2224:     periodicity = []
  /* "water_algorithm_cython.pyx":2224
 * def find_hydrogen_bonds(atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.array([])
 *     periodicity = []             # <<<<<<<<<<<<<<
 *     count = 0
 *     periodic_count = 0
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_periodicity = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2225:     count = 0
  /* "water_algorithm_cython.pyx":2225
 *     result = np.array([])
 *     periodicity = []
 *     count = 0             # <<<<<<<<<<<<<<
 *     periodic_count = 0
 *     for i in range(len(atom_positions)):
 */
  __pyx_v_count = 0;
 2226:     periodic_count = 0
  /* "water_algorithm_cython.pyx":2226
 *     periodicity = []
 *     count = 0
 *     periodic_count = 0             # <<<<<<<<<<<<<<
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_positions[i], atom_position, False, cell)
 */
  __pyx_v_periodic_count = 0;
 2227:     for i in range(len(atom_positions)):
  /* "water_algorithm_cython.pyx":2227
 *     count = 0
 *     periodic_count = 0
 *     for i in range(len(atom_positions)):             # <<<<<<<<<<<<<<
 *         distance = get_distance(atom_positions[i], atom_position, False, cell)
 *         if(distance < 1.95 and distance>1.50):
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_atom_positions); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = 0;
 2228:         distance = get_distance(atom_positions[i], atom_position, False, cell)
    /* "water_algorithm_cython.pyx":2228
 *     periodic_count = 0
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_positions[i], atom_position, False, cell)             # <<<<<<<<<<<<<<
 *         if(distance < 1.95 and distance>1.50):
 *             result = np.append(result, i)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_distance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_atom_position);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_atom_position);
    __Pyx_GIVEREF(__pyx_v_atom_position);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_cell);
    PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_cell);
    __Pyx_GIVEREF(__pyx_v_cell);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_v_distance);
    __pyx_v_distance = __pyx_t_6;
    __pyx_t_6 = 0;
 2229:         if(distance < 1.95 and distance>1.50):
    /* "water_algorithm_cython.pyx":2229
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_positions[i], atom_position, False, cell)
 *         if(distance < 1.95 and distance>1.50):             # <<<<<<<<<<<<<<
 *             result = np.append(result, i)
 *             periodicity.append(False)
 */
    __pyx_t_6 = PyFloat_FromDouble(1.95); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_distance, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_8) {
      __pyx_t_7 = PyFloat_FromDouble(1.50); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = PyObject_RichCompare(__pyx_v_distance, __pyx_t_7, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __pyx_t_9;
    } else {
      __pyx_t_10 = __pyx_t_8;
    }
    if (__pyx_t_10) {
 2230:             result = np.append(result, i)
      /* "water_algorithm_cython.pyx":2230
 *         distance = get_distance(atom_positions[i], atom_position, False, cell)
 *         if(distance < 1.95 and distance>1.50):
 *             result = np.append(result, i)             # <<<<<<<<<<<<<<
 *             periodicity.append(False)
 *             count = count +1
 */
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__append); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_result);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_result);
      __Pyx_GIVEREF(__pyx_v_result);
      __Pyx_INCREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_t_1;
      __pyx_t_1 = 0;
 2231:             periodicity.append(False)
      /* "water_algorithm_cython.pyx":2231
 *         if(distance < 1.95 and distance>1.50):
 *             result = np.append(result, i)
 *             periodicity.append(False)             # <<<<<<<<<<<<<<
 *             count = count +1
 *         if periodic:
 */
      __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_periodicity, __pyx_t_1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 2232:             count = count +1
      /* "water_algorithm_cython.pyx":2232
 *             result = np.append(result, i)
 *             periodicity.append(False)
 *             count = count +1             # <<<<<<<<<<<<<<
 *         if periodic:
 *             periodic_distance,  real_position = get_periodic_distance(atom_position,  atom_positions[i], cell)
 */
      __pyx_v_count = (__pyx_v_count + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
 2233:         if periodic:
    /* "water_algorithm_cython.pyx":2233
 *             periodicity.append(False)
 *             count = count +1
 *         if periodic:             # <<<<<<<<<<<<<<
 *             periodic_distance,  real_position = get_periodic_distance(atom_position,  atom_positions[i], cell)
 *             if(periodic_distance < 1.95 and periodic_distance>1.50):
 */
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_periodic); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_10) {
 2234:             periodic_distance,  real_position = get_periodic_distance(atom_position,  atom_positions[i], cell)
      /* "water_algorithm_cython.pyx":2234
 *             count = count +1
 *         if periodic:
 *             periodic_distance,  real_position = get_periodic_distance(atom_position,  atom_positions[i], cell)             # <<<<<<<<<<<<<<
 *             if(periodic_distance < 1.95 and periodic_distance>1.50):
 *                 result = np.append(result, i)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_106); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_atom_position);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_atom_position);
      __Pyx_GIVEREF(__pyx_v_atom_position);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_cell);
      PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_cell);
      __Pyx_GIVEREF(__pyx_v_cell);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
        PyObject* sequence = __pyx_t_6;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        #endif
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      {
        Py_ssize_t index = -1;
        __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_1 = __pyx_t_12(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L7_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_1);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_2), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_periodic_distance);
      __pyx_v_periodic_distance = __pyx_t_7;
      __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_v_real_position);
      __pyx_v_real_position = __pyx_t_1;
      __pyx_t_1 = 0;
 2235:             if(periodic_distance < 1.95 and periodic_distance>1.50):
      /* "water_algorithm_cython.pyx":2235
 *         if periodic:
 *             periodic_distance,  real_position = get_periodic_distance(atom_position,  atom_positions[i], cell)
 *             if(periodic_distance < 1.95 and periodic_distance>1.50):             # <<<<<<<<<<<<<<
 *                 result = np.append(result, i)
 *                 periodicity.append(True)
 */
      __pyx_t_6 = PyFloat_FromDouble(1.95); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_periodic_distance, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_10) {
        __pyx_t_1 = PyFloat_FromDouble(1.50); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = PyObject_RichCompare(__pyx_v_periodic_distance, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_9 = __pyx_t_8;
      } else {
        __pyx_t_9 = __pyx_t_10;
      }
      if (__pyx_t_9) {
 2236:                 result = np.append(result, i)
        /* "water_algorithm_cython.pyx":2236
 *             periodic_distance,  real_position = get_periodic_distance(atom_position,  atom_positions[i], cell)
 *             if(periodic_distance < 1.95 and periodic_distance>1.50):
 *                 result = np.append(result, i)             # <<<<<<<<<<<<<<
 *                 periodicity.append(True)
 *                 count = count +1
 */
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_v_result);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_result);
        __Pyx_GIVEREF(__pyx_v_result);
        __Pyx_INCREF(__pyx_v_i);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_i);
        __Pyx_GIVEREF(__pyx_v_i);
        __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_v_result);
        __pyx_v_result = __pyx_t_7;
        __pyx_t_7 = 0;
 2237:                 periodicity.append(True)
        /* "water_algorithm_cython.pyx":2237
 *             if(periodic_distance < 1.95 and periodic_distance>1.50):
 *                 result = np.append(result, i)
 *                 periodicity.append(True)             # <<<<<<<<<<<<<<
 *                 count = count +1
 *     #print "Molecules hydrogen bond count %i " %  (count)
 */
        __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_periodicity, __pyx_t_7); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 2238:                 count = count +1
        /* "water_algorithm_cython.pyx":2238
 *                 result = np.append(result, i)
 *                 periodicity.append(True)
 *                 count = count +1             # <<<<<<<<<<<<<<
 *     #print "Molecules hydrogen bond count %i " %  (count)
 *     return result, periodicity, count
 */
        __pyx_v_count = (__pyx_v_count + 1);
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2239:     #print "Molecules hydrogen bond count %i " %  (count)
 2240:     return result, periodicity, count
  /* "water_algorithm_cython.pyx":2240
 *                 count = count +1
 *     #print "Molecules hydrogen bond count %i " %  (count)
 *     return result, periodicity, count             # <<<<<<<<<<<<<<
 * 
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __Pyx_INCREF(((PyObject *)__pyx_v_periodicity));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_periodicity));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_periodicity));
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("water_algorithm_cython.find_hydrogen_bonds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_periodicity);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_distance);
  __Pyx_XDECREF(__pyx_v_periodic_distance);
  __Pyx_XDECREF(__pyx_v_real_position);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_7nearest_neighbors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_22water_algorithm_cython_7nearest_neighbors = {__Pyx_NAMESTR("nearest_neighbors"), (PyCFunction)__pyx_pw_22water_algorithm_cython_7nearest_neighbors, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_22water_algorithm_cython_7nearest_neighbors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_atom_position = 0;
  PyObject *__pyx_v_atom_positions = 0;
  PyObject *__pyx_v_periodic = 0;
  PyObject *__pyx_v_cell = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nearest_neighbors (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__atom_position,&__pyx_n_s__atom_positions,&__pyx_n_s__periodic,&__pyx_n_s__cell,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_k_186;
 2241: 
 2242: def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):
    /* "water_algorithm_cython.pyx":2242
 *     return result, periodicity, count
 * 
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.ndarray(4)
 *     count = 0
 */
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_position)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("nearest_neighbors", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nearest_neighbors") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_atom_position = values[0];
    __pyx_v_atom_positions = values[1];
    __pyx_v_periodic = values[2];
    __pyx_v_cell = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("nearest_neighbors", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.nearest_neighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_6nearest_neighbors(__pyx_self, __pyx_v_atom_position, __pyx_v_atom_positions, __pyx_v_periodic, __pyx_v_cell);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_6nearest_neighbors(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_atom_position, PyObject *__pyx_v_atom_positions, PyObject *__pyx_v_periodic, PyObject *__pyx_v_cell) {
  PyObject *__pyx_v_result = NULL;
  long __pyx_v_count;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_distance = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nearest_neighbors", 0);

  /* "water_algorithm_cython.pyx":2242
 *     return result, periodicity, count
 * 
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.ndarray(4)
 *     count = 0
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_186 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "water_algorithm_cython.pyx":2242
 *     return result, periodicity, count
 * 
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.ndarray(4)
 *     count = 0
 */
  __pyx_k_tuple_251 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__atom_position), ((PyObject *)__pyx_n_s__atom_positions), ((PyObject *)__pyx_n_s__periodic), ((PyObject *)__pyx_n_s__cell), ((PyObject *)__pyx_n_s__result), ((PyObject *)__pyx_n_s__count), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__distance)); if (unlikely(!__pyx_k_tuple_251)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_251);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_251));
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_7nearest_neighbors, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__nearest_neighbors, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_252 = (PyObject*)__Pyx_PyCode_New(4, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_251, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s__nearest_neighbors, 2242, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_252)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2243:     result = np.ndarray(4)
  /* "water_algorithm_cython.pyx":2243
 * 
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.ndarray(4)             # <<<<<<<<<<<<<<
 *     count = 0
 *     for i in range(len(atom_positions)):
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_k_tuple_187), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "water_algorithm_cython.pyx":2243
 * 
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.ndarray(4)             # <<<<<<<<<<<<<<
 *     count = 0
 *     for i in range(len(atom_positions)):
 */
  __pyx_k_tuple_187 = PyTuple_Pack(1, __pyx_int_4); if (unlikely(!__pyx_k_tuple_187)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_187);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_187));
 2244:     count = 0
  /* "water_algorithm_cython.pyx":2244
 * def nearest_neighbors(atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.ndarray(4)
 *     count = 0             # <<<<<<<<<<<<<<
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_positions[i], atom_position, periodic=periodic, cell=cell)
 */
  __pyx_v_count = 0;
 2245:     for i in range(len(atom_positions)):
  /* "water_algorithm_cython.pyx":2245
 *     result = np.ndarray(4)
 *     count = 0
 *     for i in range(len(atom_positions)):             # <<<<<<<<<<<<<<
 *         distance = get_distance(atom_positions[i], atom_position, periodic=periodic, cell=cell)
 *         if(distance == 2.76 or (distance > 2.510 and distance < 2.530)):
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_atom_positions); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = 0;
 2246:         distance = get_distance(atom_positions[i], atom_position, periodic=periodic, cell=cell)
    /* "water_algorithm_cython.pyx":2246
 *     count = 0
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_positions[i], atom_position, periodic=periodic, cell=cell)             # <<<<<<<<<<<<<<
 *         if(distance == 2.76 or (distance > 2.510 and distance < 2.530)):
 *             result[count] = atom_positions[i]
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_distance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_atom_position);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_atom_position);
    __Pyx_GIVEREF(__pyx_v_atom_position);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__periodic), __pyx_v_periodic) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__cell), __pyx_v_cell) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_v_distance);
    __pyx_v_distance = __pyx_t_7;
    __pyx_t_7 = 0;
 2247:         if(distance == 2.76 or (distance > 2.510 and distance < 2.530)):
    /* "water_algorithm_cython.pyx":2247
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_positions[i], atom_position, periodic=periodic, cell=cell)
 *         if(distance == 2.76 or (distance > 2.510 and distance < 2.530)):             # <<<<<<<<<<<<<<
 *             result[count] = atom_positions[i]
 *             count = count + 1
 */
    __pyx_t_7 = PyFloat_FromDouble(2.76); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_distance, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!__pyx_t_8) {
      __pyx_t_5 = PyFloat_FromDouble(2.510); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_distance, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_9) {
        __pyx_t_7 = PyFloat_FromDouble(2.530); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = PyObject_RichCompare(__pyx_v_distance, __pyx_t_7, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_11 = __pyx_t_10;
      } else {
        __pyx_t_11 = __pyx_t_9;
      }
      __pyx_t_9 = __pyx_t_11;
    } else {
      __pyx_t_9 = __pyx_t_8;
    }
    if (__pyx_t_9) {
 2248:             result[count] = atom_positions[i]
      /* "water_algorithm_cython.pyx":2248
 *         distance = get_distance(atom_positions[i], atom_position, periodic=periodic, cell=cell)
 *         if(distance == 2.76 or (distance > 2.510 and distance < 2.530)):
 *             result[count] = atom_positions[i]             # <<<<<<<<<<<<<<
 *             count = count + 1
 *     return result
 */
      __pyx_t_5 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      if (__Pyx_SetItemInt(__pyx_v_result, __pyx_v_count, __pyx_t_5, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 2249:             count = count + 1
      /* "water_algorithm_cython.pyx":2249
 *         if(distance == 2.76 or (distance > 2.510 and distance < 2.530)):
 *             result[count] = atom_positions[i]
 *             count = count + 1             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
      __pyx_v_count = (__pyx_v_count + 1);
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2250:     return result
  /* "water_algorithm_cython.pyx":2250
 *             result[count] = atom_positions[i]
 *             count = count + 1
 *     return result             # <<<<<<<<<<<<<<
 * 
 * def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_result);
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("water_algorithm_cython.nearest_neighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_distance);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_9nearest_neighbors_no(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_22water_algorithm_cython_9nearest_neighbors_no = {__Pyx_NAMESTR("nearest_neighbors_no"), (PyCFunction)__pyx_pw_22water_algorithm_cython_9nearest_neighbors_no, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_22water_algorithm_cython_9nearest_neighbors_no(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_water_algorithm = 0;
  PyObject *__pyx_v_atom_no = 0;
  PyObject *__pyx_v_atom_position = 0;
  PyObject *__pyx_v_atom_positions = 0;
  PyObject *__pyx_v_periodic = 0;
  PyObject *__pyx_v_cell = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nearest_neighbors_no (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_algorithm,&__pyx_n_s__atom_no,&__pyx_n_s__atom_position,&__pyx_n_s__atom_positions,&__pyx_n_s__periodic,&__pyx_n_s__cell,0};
    PyObject* values[6] = {0,0,0,0,0,0};
    values[4] = __pyx_k_188;
 2251: 
 2252: def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):
    /* "water_algorithm_cython.pyx":2252
 *     return result
 * 
 * def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.array([],  dtype=DTYPE)
 *     periodicity = []
 */
    values[5] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_algorithm)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_no)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("nearest_neighbors_no", 0, 4, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_position)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("nearest_neighbors_no", 0, 4, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("nearest_neighbors_no", 0, 4, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nearest_neighbors_no") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_water_algorithm = values[0];
    __pyx_v_atom_no = values[1];
    __pyx_v_atom_position = values[2];
    __pyx_v_atom_positions = values[3];
    __pyx_v_periodic = values[4];
    __pyx_v_cell = values[5];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("nearest_neighbors_no", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.nearest_neighbors_no", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_8nearest_neighbors_no(__pyx_self, __pyx_v_water_algorithm, __pyx_v_atom_no, __pyx_v_atom_position, __pyx_v_atom_positions, __pyx_v_periodic, __pyx_v_cell);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_8nearest_neighbors_no(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_water_algorithm, PyObject *__pyx_v_atom_no, PyObject *__pyx_v_atom_position, PyObject *__pyx_v_atom_positions, PyObject *__pyx_v_periodic, PyObject *__pyx_v_cell) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_periodicity = NULL;
  PyObject *__pyx_v_periodicity_axis = NULL;
  PyObject *__pyx_v_sortlist = NULL;
  PyObject *__pyx_v_count = NULL;
  PyObject *__pyx_v_min_distance = NULL;
  PyObject *__pyx_v_max_distance = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_distance = NULL;
  PyObject *__pyx_v_ind = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nearest_neighbors_no", 0);

  /* "water_algorithm_cython.pyx":2252
 *     return result
 * 
 * def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.array([],  dtype=DTYPE)
 *     periodicity = []
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_188 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "water_algorithm_cython.pyx":2252
 *     return result
 * 
 * def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = np.array([],  dtype=DTYPE)
 *     periodicity = []
 */
  __pyx_k_tuple_253 = PyTuple_Pack(16, ((PyObject *)__pyx_n_s__water_algorithm), ((PyObject *)__pyx_n_s__atom_no), ((PyObject *)__pyx_n_s__atom_position), ((PyObject *)__pyx_n_s__atom_positions), ((PyObject *)__pyx_n_s__periodic), ((PyObject *)__pyx_n_s__cell), ((PyObject *)__pyx_n_s__result), ((PyObject *)__pyx_n_s__periodicity), ((PyObject *)__pyx_n_s__periodicity_axis), ((PyObject *)__pyx_n_s__sortlist), ((PyObject *)__pyx_n_s__count), ((PyObject *)__pyx_n_s__min_distance), ((PyObject *)__pyx_n_s__max_distance), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__distance), ((PyObject *)__pyx_n_s__ind)); if (unlikely(!__pyx_k_tuple_253)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_253);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_253));
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_9nearest_neighbors_no, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_193, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_254 = (PyObject*)__Pyx_PyCode_New(6, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_253, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s_193, 2252, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_254)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2253:     result = np.array([],  dtype=DTYPE)
  /* "water_algorithm_cython.pyx":2253
 * 
 * def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.array([],  dtype=DTYPE)             # <<<<<<<<<<<<<<
 *     periodicity = []
 *     periodicity_axis = []
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_result = __pyx_t_4;
  __pyx_t_4 = 0;
 2254:     periodicity = []
  /* "water_algorithm_cython.pyx":2254
 * def nearest_neighbors_no(water_algorithm,  atom_no,  atom_position, atom_positions, periodic=False, cell=None):
 *     result = np.array([],  dtype=DTYPE)
 *     periodicity = []             # <<<<<<<<<<<<<<
 *     periodicity_axis = []
 *     sortlist = np.zeros((0, 3),  dtype=DTYPE)
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_periodicity = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 2255:     periodicity_axis = []
  /* "water_algorithm_cython.pyx":2255
 *     result = np.array([],  dtype=DTYPE)
 *     periodicity = []
 *     periodicity_axis = []             # <<<<<<<<<<<<<<
 *     sortlist = np.zeros((0, 3),  dtype=DTYPE)
 *     count = 0
 */
  __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_periodicity_axis = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
 2256:     sortlist = np.zeros((0, 3),  dtype=DTYPE)
  /* "water_algorithm_cython.pyx":2256
 *     periodicity = []
 *     periodicity_axis = []
 *     sortlist = np.zeros((0, 3),  dtype=DTYPE)             # <<<<<<<<<<<<<<
 *     count = 0
 *     min_distance = water_algorithm.O_O_distance * 0.85
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "water_algorithm_cython.pyx":2256
 *     periodicity = []
 *     periodicity_axis = []
 *     sortlist = np.zeros((0, 3),  dtype=DTYPE)             # <<<<<<<<<<<<<<
 *     count = 0
 *     min_distance = water_algorithm.O_O_distance * 0.85
 */
  __pyx_k_tuple_189 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_3); if (unlikely(!__pyx_k_tuple_189)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_189);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_189));
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_190), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_v_sortlist = __pyx_t_3;
  __pyx_t_3 = 0;
  __pyx_k_tuple_190 = PyTuple_Pack(1, ((PyObject *)__pyx_k_tuple_189)); if (unlikely(!__pyx_k_tuple_190)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_190);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_190));
 2257:     count = 0
  /* "water_algorithm_cython.pyx":2257
 *     periodicity_axis = []
 *     sortlist = np.zeros((0, 3),  dtype=DTYPE)
 *     count = 0             # <<<<<<<<<<<<<<
 *     min_distance = water_algorithm.O_O_distance * 0.85
 *     max_distance = water_algorithm.O_O_distance * 1.15
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_count = __pyx_int_0;
 2258:     min_distance = water_algorithm.O_O_distance * 0.85
  /* "water_algorithm_cython.pyx":2258
 *     sortlist = np.zeros((0, 3),  dtype=DTYPE)
 *     count = 0
 *     min_distance = water_algorithm.O_O_distance * 0.85             # <<<<<<<<<<<<<<
 *     max_distance = water_algorithm.O_O_distance * 1.15
 *     for i in range(len(atom_positions)):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_water_algorithm, __pyx_n_s__O_O_distance); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(0.85); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_min_distance = __pyx_t_1;
  __pyx_t_1 = 0;
 2259:     max_distance = water_algorithm.O_O_distance * 1.15
  /* "water_algorithm_cython.pyx":2259
 *     count = 0
 *     min_distance = water_algorithm.O_O_distance * 0.85
 *     max_distance = water_algorithm.O_O_distance * 1.15             # <<<<<<<<<<<<<<
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_position,  atom_positions[i] , periodic=False)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_water_algorithm, __pyx_n_s__O_O_distance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyFloat_FromDouble(1.15); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_max_distance = __pyx_t_3;
  __pyx_t_3 = 0;
 2260:     for i in range(len(atom_positions)):
  /* "water_algorithm_cython.pyx":2260
 *     min_distance = water_algorithm.O_O_distance * 0.85
 *     max_distance = water_algorithm.O_O_distance * 1.15
 *     for i in range(len(atom_positions)):             # <<<<<<<<<<<<<<
 *         distance = get_distance(atom_position,  atom_positions[i] , periodic=False)
 *         if (distance > min_distance and distance < max_distance):
 */
  __pyx_t_5 = PyObject_Length(__pyx_v_atom_positions); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
      if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_3;
    __pyx_t_3 = 0;
 2261:         distance = get_distance(atom_position,  atom_positions[i] , periodic=False)
    /* "water_algorithm_cython.pyx":2261
 *     max_distance = water_algorithm.O_O_distance * 1.15
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_position,  atom_positions[i] , periodic=False)             # <<<<<<<<<<<<<<
 *         if (distance > min_distance and distance < max_distance):
 *             result = np.append(result, i)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_distance); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_atom_position);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_atom_position);
    __Pyx_GIVEREF(__pyx_v_atom_position);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__periodic), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_distance);
    __pyx_v_distance = __pyx_t_7;
    __pyx_t_7 = 0;
 2262:         if (distance > min_distance and distance < max_distance):
    /* "water_algorithm_cython.pyx":2262
 *     for i in range(len(atom_positions)):
 *         distance = get_distance(atom_position,  atom_positions[i] , periodic=False)
 *         if (distance > min_distance and distance < max_distance):             # <<<<<<<<<<<<<<
 *             result = np.append(result, i)
 *             periodicity = np.append(periodicity, False)
 */
    __pyx_t_7 = PyObject_RichCompare(__pyx_v_distance, __pyx_v_min_distance, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_8) {
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_distance, __pyx_v_max_distance, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_10 = __pyx_t_9;
    } else {
      __pyx_t_10 = __pyx_t_8;
    }
    if (__pyx_t_10) {
 2263:             result = np.append(result, i)
      /* "water_algorithm_cython.pyx":2263
 *         distance = get_distance(atom_position,  atom_positions[i] , periodic=False)
 *         if (distance > min_distance and distance < max_distance):
 *             result = np.append(result, i)             # <<<<<<<<<<<<<<
 *             periodicity = np.append(periodicity, False)
 *             periodicity_axis.append(13)
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_result);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_result);
      __Pyx_GIVEREF(__pyx_v_result);
      __Pyx_INCREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_t_2;
      __pyx_t_2 = 0;
 2264:             periodicity = np.append(periodicity, False)
      /* "water_algorithm_cython.pyx":2264
 *         if (distance > min_distance and distance < max_distance):
 *             result = np.append(result, i)
 *             periodicity = np.append(periodicity, False)             # <<<<<<<<<<<<<<
 *             periodicity_axis.append(13)
 *             count = count + 1
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__append); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_periodicity);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_periodicity);
      __Pyx_GIVEREF(__pyx_v_periodicity);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_periodicity);
      __pyx_v_periodicity = __pyx_t_2;
      __pyx_t_2 = 0;
 2265:             periodicity_axis.append(13)
      /* "water_algorithm_cython.pyx":2265
 *             result = np.append(result, i)
 *             periodicity = np.append(periodicity, False)
 *             periodicity_axis.append(13)             # <<<<<<<<<<<<<<
 *             count = count + 1
 *             sortlist = np.vstack((sortlist,  atom_positions[i]))
 */
      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_v_periodicity_axis, __pyx_int_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 2266:             count = count + 1
      /* "water_algorithm_cython.pyx":2266
 *             periodicity = np.append(periodicity, False)
 *             periodicity_axis.append(13)
 *             count = count + 1             # <<<<<<<<<<<<<<
 *             sortlist = np.vstack((sortlist,  atom_positions[i]))
 *         if periodic:
 */
      __pyx_t_2 = PyNumber_Add(__pyx_v_count, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_count);
      __pyx_v_count = __pyx_t_2;
      __pyx_t_2 = 0;
 2267:             sortlist = np.vstack((sortlist,  atom_positions[i]))
      /* "water_algorithm_cython.pyx":2267
 *             periodicity_axis.append(13)
 *             count = count + 1
 *             sortlist = np.vstack((sortlist,  atom_positions[i]))             # <<<<<<<<<<<<<<
 *         if periodic:
 *             result, periodicity, periodicity_axis, count, sortlist = add_periodic_neighbors(atom_position, atom_positions[i], cell, min_distance, max_distance, i, result, periodicity, periodicity_axis, count, sortlist)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__vstack); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_sortlist);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_sortlist);
      __Pyx_GIVEREF(__pyx_v_sortlist);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_7));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_sortlist);
      __pyx_v_sortlist = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L5;
    }
    __pyx_L5:;
 2268:         if periodic:
    /* "water_algorithm_cython.pyx":2268
 *             count = count + 1
 *             sortlist = np.vstack((sortlist,  atom_positions[i]))
 *         if periodic:             # <<<<<<<<<<<<<<
 *             result, periodicity, periodicity_axis, count, sortlist = add_periodic_neighbors(atom_position, atom_positions[i], cell, min_distance, max_distance, i, result, periodicity, periodicity_axis, count, sortlist)
 * 
 */
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_periodic); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_10) {
 2269:             result, periodicity, periodicity_axis, count, sortlist = add_periodic_neighbors(atom_position, atom_positions[i], cell, min_distance, max_distance, i, result, periodicity, periodicity_axis, count, sortlist)
      /* "water_algorithm_cython.pyx":2269
 *             sortlist = np.vstack((sortlist,  atom_positions[i]))
 *         if periodic:
 *             result, periodicity, periodicity_axis, count, sortlist = add_periodic_neighbors(atom_position, atom_positions[i], cell, min_distance, max_distance, i, result, periodicity, periodicity_axis, count, sortlist)             # <<<<<<<<<<<<<<
 * 
 *     # following lines are deprecated because of the symmetry finding algorithm
 */
      __pyx_t_7 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = ((PyObject *)__pyx_f_22water_algorithm_cython_add_periodic_neighbors(__pyx_v_atom_position, __pyx_t_7, __pyx_v_cell, __pyx_v_min_distance, __pyx_v_max_distance, __pyx_v_i, __pyx_v_result, __pyx_v_periodicity, __pyx_v_periodicity_axis, __pyx_v_count, __pyx_v_sortlist)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyList_CheckExact(__pyx_t_2)) {
        PyObject* sequence = __pyx_t_2;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 5)) {
          if (size > 5) __Pyx_RaiseTooManyValuesError(5);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 4); 
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_12);
        #else
        Py_ssize_t i;
        PyObject** temps[5] = {&__pyx_t_7,&__pyx_t_1,&__pyx_t_3,&__pyx_t_11,&__pyx_t_12};
        for (i=0; i < 5; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
        #endif
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      {
        Py_ssize_t index = -1;
        PyObject** temps[5] = {&__pyx_t_7,&__pyx_t_1,&__pyx_t_3,&__pyx_t_11,&__pyx_t_12};
        __pyx_t_13 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_14 = Py_TYPE(__pyx_t_13)->tp_iternext;
        for (index=0; index < 5; index++) {
          PyObject* item = __pyx_t_14(__pyx_t_13); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_14 = NULL;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L8_unpacking_done;
        __pyx_L7_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_14 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L8_unpacking_done:;
      }
      __Pyx_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_t_7;
      __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_v_periodicity);
      __pyx_v_periodicity = __pyx_t_1;
      __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_periodicity_axis);
      __pyx_v_periodicity_axis = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_count);
      __pyx_v_count = __pyx_t_11;
      __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_v_sortlist);
      __pyx_v_sortlist = __pyx_t_12;
      __pyx_t_12 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 2270: 
 2271:     # following lines are deprecated because of the symmetry finding algorithm
 2272:     ind = water_algorithm.sort_nearest_neighbors(atom_no,  sortlist,  result)
  /* "water_algorithm_cython.pyx":2272
 * 
 *     # following lines are deprecated because of the symmetry finding algorithm
 *     ind = water_algorithm.sort_nearest_neighbors(atom_no,  sortlist,  result)             # <<<<<<<<<<<<<<
 *     if ind != None:
 *         periodicity = np.array([periodicity[i] for i in ind],  dtype=DTYPE)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_water_algorithm, __pyx_n_s_191); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_atom_no);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_atom_no);
  __Pyx_GIVEREF(__pyx_v_atom_no);
  __Pyx_INCREF(__pyx_v_sortlist);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_sortlist);
  __Pyx_GIVEREF(__pyx_v_sortlist);
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __pyx_t_12 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_v_ind = __pyx_t_12;
  __pyx_t_12 = 0;
 2273:     if ind != None:
  /* "water_algorithm_cython.pyx":2273
 *     # following lines are deprecated because of the symmetry finding algorithm
 *     ind = water_algorithm.sort_nearest_neighbors(atom_no,  sortlist,  result)
 *     if ind != None:             # <<<<<<<<<<<<<<
 *         periodicity = np.array([periodicity[i] for i in ind],  dtype=DTYPE)
 *         periodicity_axis = np.array([periodicity_axis[i] for i in ind],  dtype=DTYPE)
 */
  __pyx_t_12 = PyObject_RichCompare(__pyx_v_ind, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (__pyx_t_10) {
 2274:         periodicity = np.array([periodicity[i] for i in ind],  dtype=DTYPE)
    /* "water_algorithm_cython.pyx":2274
 *     ind = water_algorithm.sort_nearest_neighbors(atom_no,  sortlist,  result)
 *     if ind != None:
 *         periodicity = np.array([periodicity[i] for i in ind],  dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         periodicity_axis = np.array([periodicity_axis[i] for i in ind],  dtype=DTYPE)
 *         result = np.array([result[i] for i in ind],  dtype=DTYPE)
 */
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (PyList_CheckExact(__pyx_v_ind) || PyTuple_CheckExact(__pyx_v_ind)) {
      __pyx_t_4 = __pyx_v_ind; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_ind); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_11 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_11); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_11 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_11 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_11)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_11);
      }
      __Pyx_XDECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_11;
      __pyx_t_11 = 0;
      __pyx_t_11 = PyObject_GetItem(__pyx_v_periodicity, __pyx_v_i); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_12, (PyObject*)__pyx_t_11))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_12));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_12));
    __pyx_t_12 = 0;
    __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_12));
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    if (PyDict_SetItem(__pyx_t_12, ((PyObject *)__pyx_n_s__dtype), __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_12)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_v_periodicity);
    __pyx_v_periodicity = __pyx_t_11;
    __pyx_t_11 = 0;
 2275:         periodicity_axis = np.array([periodicity_axis[i] for i in ind],  dtype=DTYPE)
    /* "water_algorithm_cython.pyx":2275
 *     if ind != None:
 *         periodicity = np.array([periodicity[i] for i in ind],  dtype=DTYPE)
 *         periodicity_axis = np.array([periodicity_axis[i] for i in ind],  dtype=DTYPE)             # <<<<<<<<<<<<<<
 *         result = np.array([result[i] for i in ind],  dtype=DTYPE)
 *     return result, periodicity, periodicity_axis
 */
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s__array); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    if (PyList_CheckExact(__pyx_v_ind) || PyTuple_CheckExact(__pyx_v_ind)) {
      __pyx_t_4 = __pyx_v_ind; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_ind); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_2 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_2)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_2;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(__pyx_v_periodicity_axis, __pyx_v_i); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_11, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_11));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_11));
    __pyx_t_11 = 0;
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_11));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_11, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_11)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_v_periodicity_axis);
    __pyx_v_periodicity_axis = __pyx_t_2;
    __pyx_t_2 = 0;
 2276:         result = np.array([result[i] for i in ind],  dtype=DTYPE)
    /* "water_algorithm_cython.pyx":2276
 *         periodicity = np.array([periodicity[i] for i in ind],  dtype=DTYPE)
 *         periodicity_axis = np.array([periodicity_axis[i] for i in ind],  dtype=DTYPE)
 *         result = np.array([result[i] for i in ind],  dtype=DTYPE)             # <<<<<<<<<<<<<<
 *     return result, periodicity, periodicity_axis
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__array); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyList_CheckExact(__pyx_v_ind) || PyTuple_CheckExact(__pyx_v_ind)) {
      __pyx_t_4 = __pyx_v_ind; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_ind); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_12); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_12 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_12); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_12 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_12)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_12);
      }
      __Pyx_XDECREF(__pyx_v_i);
      __pyx_v_i = __pyx_t_12;
      __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_GetItem(__pyx_v_result, __pyx_v_i); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_12))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_t_12;
    __pyx_t_12 = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;
 2277:     return result, periodicity, periodicity_axis
  /* "water_algorithm_cython.pyx":2277
 *         periodicity_axis = np.array([periodicity_axis[i] for i in ind],  dtype=DTYPE)
 *         result = np.array([result[i] for i in ind],  dtype=DTYPE)
 *     return result, periodicity, periodicity_axis             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __Pyx_INCREF(__pyx_v_periodicity);
  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_periodicity);
  __Pyx_GIVEREF(__pyx_v_periodicity);
  __Pyx_INCREF(__pyx_v_periodicity_axis);
  PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_v_periodicity_axis);
  __Pyx_GIVEREF(__pyx_v_periodicity_axis);
  __pyx_r = ((PyObject *)__pyx_t_12);
  __pyx_t_12 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("water_algorithm_cython.nearest_neighbors_no", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_periodicity);
  __Pyx_XDECREF(__pyx_v_periodicity_axis);
  __Pyx_XDECREF(__pyx_v_sortlist);
  __Pyx_XDECREF(__pyx_v_count);
  __Pyx_XDECREF(__pyx_v_min_distance);
  __Pyx_XDECREF(__pyx_v_max_distance);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_distance);
  __Pyx_XDECREF(__pyx_v_ind);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_11all_nearest_neighbors_no(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_22water_algorithm_cython_11all_nearest_neighbors_no = {__Pyx_NAMESTR("all_nearest_neighbors_no"), (PyCFunction)__pyx_pw_22water_algorithm_cython_11all_nearest_neighbors_no, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_22water_algorithm_cython_11all_nearest_neighbors_no(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_water_algorithm = 0;
  PyObject *__pyx_v_atom_positions = 0;
  PyObject *__pyx_v_periodic = 0;
  PyObject *__pyx_v_cell = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("all_nearest_neighbors_no (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__water_algorithm,&__pyx_n_s__atom_positions,&__pyx_n_s__periodic,&__pyx_n_s__cell,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = __pyx_k_192;
 2278: 
 2279: 
 2280: 
 2281: def all_nearest_neighbors_no(water_algorithm,  atom_positions, periodic=False, cell=None):
    /* "water_algorithm_cython.pyx":2281
 * 
 * 
 * def all_nearest_neighbors_no(water_algorithm,  atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = []
 *     periodicities = []
 */
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__water_algorithm)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__atom_positions)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("all_nearest_neighbors_no", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodic);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cell);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "all_nearest_neighbors_no") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_water_algorithm = values[0];
    __pyx_v_atom_positions = values[1];
    __pyx_v_periodic = values[2];
    __pyx_v_cell = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("all_nearest_neighbors_no", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.all_nearest_neighbors_no", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_10all_nearest_neighbors_no(__pyx_self, __pyx_v_water_algorithm, __pyx_v_atom_positions, __pyx_v_periodic, __pyx_v_cell);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_22water_algorithm_cython_10all_nearest_neighbors_no(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_water_algorithm, PyObject *__pyx_v_atom_positions, PyObject *__pyx_v_periodic, PyObject *__pyx_v_cell) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_v_periodicities = NULL;
  PyObject *__pyx_v_periodicity_axis = NULL;
  CYTHON_UNUSED long __pyx_v_count;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_nos = NULL;
  PyObject *__pyx_v_periodicity = NULL;
  PyObject *__pyx_v_periodicity_ax = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("all_nearest_neighbors_no", 0);

  /* "water_algorithm_cython.pyx":2281
 * 
 * 
 * def all_nearest_neighbors_no(water_algorithm,  atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = []
 *     periodicities = []
 */
  __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_k_192 = __pyx_t_6;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;

  /* "water_algorithm_cython.pyx":2281
 * 
 * 
 * def all_nearest_neighbors_no(water_algorithm,  atom_positions, periodic=False, cell=None):             # <<<<<<<<<<<<<<
 *     result = []
 *     periodicities = []
 */
  __pyx_k_tuple_255 = PyTuple_Pack(12, ((PyObject *)__pyx_n_s__water_algorithm), ((PyObject *)__pyx_n_s__atom_positions), ((PyObject *)__pyx_n_s__periodic), ((PyObject *)__pyx_n_s__cell), ((PyObject *)__pyx_n_s__result), ((PyObject *)__pyx_n_s__periodicities), ((PyObject *)__pyx_n_s__periodicity_axis), ((PyObject *)__pyx_n_s__count), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__nos), ((PyObject *)__pyx_n_s__periodicity), ((PyObject *)__pyx_n_s__periodicity_ax)); if (unlikely(!__pyx_k_tuple_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_255);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_255));
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_11all_nearest_neighbors_no, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_13, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_256 = (PyObject*)__Pyx_PyCode_New(4, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_255, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s_13, 2281, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2282:     result = []
  /* "water_algorithm_cython.pyx":2282
 * 
 * def all_nearest_neighbors_no(water_algorithm,  atom_positions, periodic=False, cell=None):
 *     result = []             # <<<<<<<<<<<<<<
 *     periodicities = []
 *     periodicity_axis = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2283:     periodicities = []
  /* "water_algorithm_cython.pyx":2283
 * def all_nearest_neighbors_no(water_algorithm,  atom_positions, periodic=False, cell=None):
 *     result = []
 *     periodicities = []             # <<<<<<<<<<<<<<
 *     periodicity_axis = []
 *     count = 0
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_periodicities = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2284:     periodicity_axis = []
  /* "water_algorithm_cython.pyx":2284
 *     result = []
 *     periodicities = []
 *     periodicity_axis = []             # <<<<<<<<<<<<<<
 *     count = 0
 *     for i in range(len(atom_positions)):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_periodicity_axis = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2285:     count = 0
  /* "water_algorithm_cython.pyx":2285
 *     periodicities = []
 *     periodicity_axis = []
 *     count = 0             # <<<<<<<<<<<<<<
 *     for i in range(len(atom_positions)):
 *         nos, periodicity, periodicity_ax = nearest_neighbors_no(water_algorithm,  i,  atom_positions[i], atom_positions, periodic, cell)
 */
  __pyx_v_count = 0;
 2286:     for i in range(len(atom_positions)):
  /* "water_algorithm_cython.pyx":2286
 *     periodicity_axis = []
 *     count = 0
 *     for i in range(len(atom_positions)):             # <<<<<<<<<<<<<<
 *         nos, periodicity, periodicity_ax = nearest_neighbors_no(water_algorithm,  i,  atom_positions[i], atom_positions, periodic, cell)
 *         nos, periodicity, periodicity_ax = add_dangling_bonds_to_nearest_neighbors(i,  nos,  periodicity, periodicity_ax)
 */
  __pyx_t_2 = PyObject_Length(__pyx_v_atom_positions); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_4(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_1 = 0;
 2287:         nos, periodicity, periodicity_ax = nearest_neighbors_no(water_algorithm,  i,  atom_positions[i], atom_positions, periodic, cell)
    /* "water_algorithm_cython.pyx":2287
 *     count = 0
 *     for i in range(len(atom_positions)):
 *         nos, periodicity, periodicity_ax = nearest_neighbors_no(water_algorithm,  i,  atom_positions[i], atom_positions, periodic, cell)             # <<<<<<<<<<<<<<
 *         nos, periodicity, periodicity_ax = add_dangling_bonds_to_nearest_neighbors(i,  nos,  periodicity, periodicity_ax)
 *         result.append(nos)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_193); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_GetItem(__pyx_v_atom_positions, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_water_algorithm);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_water_algorithm);
    __Pyx_GIVEREF(__pyx_v_water_algorithm);
    __Pyx_INCREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_atom_positions);
    PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_atom_positions);
    __Pyx_GIVEREF(__pyx_v_atom_positions);
    __Pyx_INCREF(__pyx_v_periodic);
    PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_v_periodic);
    __Pyx_GIVEREF(__pyx_v_periodic);
    __Pyx_INCREF(__pyx_v_cell);
    PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_v_cell);
    __Pyx_GIVEREF(__pyx_v_cell);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_1 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 2; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_nos);
    __pyx_v_nos = __pyx_t_6;
    __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_v_periodicity);
    __pyx_v_periodicity = __pyx_t_1;
    __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_v_periodicity_ax);
    __pyx_v_periodicity_ax = __pyx_t_7;
    __pyx_t_7 = 0;
 2288:         nos, periodicity, periodicity_ax = add_dangling_bonds_to_nearest_neighbors(i,  nos,  periodicity, periodicity_ax)
    /* "water_algorithm_cython.pyx":2288
 *     for i in range(len(atom_positions)):
 *         nos, periodicity, periodicity_ax = nearest_neighbors_no(water_algorithm,  i,  atom_positions[i], atom_positions, periodic, cell)
 *         nos, periodicity, periodicity_ax = add_dangling_bonds_to_nearest_neighbors(i,  nos,  periodicity, periodicity_ax)             # <<<<<<<<<<<<<<
 *         result.append(nos)
 *         periodicities.append(periodicity)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_194); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    __Pyx_INCREF(__pyx_v_nos);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_nos);
    __Pyx_GIVEREF(__pyx_v_nos);
    __Pyx_INCREF(__pyx_v_periodicity);
    PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_periodicity);
    __Pyx_GIVEREF(__pyx_v_periodicity);
    __Pyx_INCREF(__pyx_v_periodicity_ax);
    PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_periodicity_ax);
    __Pyx_GIVEREF(__pyx_v_periodicity_ax);
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 1; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 2; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L8_unpacking_done:;
    }
    __Pyx_DECREF(__pyx_v_nos);
    __pyx_v_nos = __pyx_t_7;
    __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_v_periodicity);
    __pyx_v_periodicity = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_periodicity_ax);
    __pyx_v_periodicity_ax = __pyx_t_6;
    __pyx_t_6 = 0;
 2289:         result.append(nos)
    /* "water_algorithm_cython.pyx":2289
 *         nos, periodicity, periodicity_ax = nearest_neighbors_no(water_algorithm,  i,  atom_positions[i], atom_positions, periodic, cell)
 *         nos, periodicity, periodicity_ax = add_dangling_bonds_to_nearest_neighbors(i,  nos,  periodicity, periodicity_ax)
 *         result.append(nos)             # <<<<<<<<<<<<<<
 *         periodicities.append(periodicity)
 *         periodicity_axis.append(periodicity_ax)
 */
    __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_nos); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2290:         periodicities.append(periodicity)
    /* "water_algorithm_cython.pyx":2290
 *         nos, periodicity, periodicity_ax = add_dangling_bonds_to_nearest_neighbors(i,  nos,  periodicity, periodicity_ax)
 *         result.append(nos)
 *         periodicities.append(periodicity)             # <<<<<<<<<<<<<<
 *         periodicity_axis.append(periodicity_ax)
 *     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)
 */
    __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_periodicities, __pyx_v_periodicity); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2291:         periodicity_axis.append(periodicity_ax)
    /* "water_algorithm_cython.pyx":2291
 *         result.append(nos)
 *         periodicities.append(periodicity)
 *         periodicity_axis.append(periodicity_ax)             # <<<<<<<<<<<<<<
 *     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)
 * 
 */
    __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_periodicity_axis, __pyx_v_periodicity_ax); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2292:     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)
  /* "water_algorithm_cython.pyx":2292
 *         periodicities.append(periodicity)
 *         periodicity_axis.append(periodicity_ax)
 *     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)             # <<<<<<<<<<<<<<
 * 
 * def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_result));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_result));
  __Pyx_INCREF(((PyObject *)__pyx_v_periodicities));
  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_periodicities));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_periodicities));
  __Pyx_INCREF(((PyObject *)__pyx_v_periodicity_axis));
  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_v_periodicity_axis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_periodicity_axis));
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("water_algorithm_cython.all_nearest_neighbors_no", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_periodicities);
  __Pyx_XDECREF(__pyx_v_periodicity_axis);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_nos);
  __Pyx_XDECREF(__pyx_v_periodicity);
  __Pyx_XDECREF(__pyx_v_periodicity_ax);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_22water_algorithm_cython_13add_dangling_bonds_to_nearest_neighbors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_22water_algorithm_cython_13add_dangling_bonds_to_nearest_neighbors = {__Pyx_NAMESTR("add_dangling_bonds_to_nearest_neighbors"), (PyCFunction)__pyx_pw_22water_algorithm_cython_13add_dangling_bonds_to_nearest_neighbors, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_22water_algorithm_cython_13add_dangling_bonds_to_nearest_neighbors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_molecule_no = 0;
  PyObject *__pyx_v_nearest_neighbors_nos = 0;
  PyObject *__pyx_v_periodicity = 0;
  PyObject *__pyx_v_periodicity_axis = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_dangling_bonds_to_nearest_neighbors (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__molecule_no,&__pyx_n_s_14,&__pyx_n_s__periodicity,&__pyx_n_s__periodicity_axis,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__molecule_no)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_14)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_dangling_bonds_to_nearest_neighbors", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodicity)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_dangling_bonds_to_nearest_neighbors", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__periodicity_axis)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("add_dangling_bonds_to_nearest_neighbors", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "add_dangling_bonds_to_nearest_neighbors") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_molecule_no = values[0];
    __pyx_v_nearest_neighbors_nos = values[1];
    __pyx_v_periodicity = values[2];
    __pyx_v_periodicity_axis = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_dangling_bonds_to_nearest_neighbors", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("water_algorithm_cython.add_dangling_bonds_to_nearest_neighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_22water_algorithm_cython_12add_dangling_bonds_to_nearest_neighbors(__pyx_self, __pyx_v_molecule_no, __pyx_v_nearest_neighbors_nos, __pyx_v_periodicity, __pyx_v_periodicity_axis);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2293: 
 2294: def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):
/* "water_algorithm_cython.pyx":2294
 *     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)
 * 
 * def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):             # <<<<<<<<<<<<<<
 *     if len(nearest_neighbors_nos) == 4:
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis
 */

static PyObject *__pyx_pf_22water_algorithm_cython_12add_dangling_bonds_to_nearest_neighbors(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_molecule_no, PyObject *__pyx_v_nearest_neighbors_nos, PyObject *__pyx_v_periodicity, PyObject *__pyx_v_periodicity_axis) {
  PyObject *__pyx_v_result = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_dangling_bonds_to_nearest_neighbors", 0);
  __Pyx_INCREF(__pyx_v_periodicity);
  __Pyx_INCREF(__pyx_v_periodicity_axis);

  /* "water_algorithm_cython.pyx":2294
 *     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)
 * 
 * def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):             # <<<<<<<<<<<<<<
 *     if len(nearest_neighbors_nos) == 4:
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis
 */
  __pyx_k_tuple_257 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__molecule_no), ((PyObject *)__pyx_n_s_14), ((PyObject *)__pyx_n_s__periodicity), ((PyObject *)__pyx_n_s__periodicity_axis), ((PyObject *)__pyx_n_s__result)); if (unlikely(!__pyx_k_tuple_257)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_257);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_257));

  /* "water_algorithm_cython.pyx":2294
 *     return np.array([result, periodicities, periodicity_axis], dtype=DTYPE)
 * 
 * def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):             # <<<<<<<<<<<<<<
 *     if len(nearest_neighbors_nos) == 4:
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis
 */
  __pyx_t_6 = PyCFunction_NewEx(&__pyx_mdef_22water_algorithm_cython_13add_dangling_bonds_to_nearest_neighbors, NULL, __pyx_n_s_246); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_194, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_k_codeobj_258 = (PyObject*)__Pyx_PyCode_New(4, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_257, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_245, __pyx_n_s_194, 2294, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_258)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 2295:     if len(nearest_neighbors_nos) == 4:
  /* "water_algorithm_cython.pyx":2295
 * 
 * def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):
 *     if len(nearest_neighbors_nos) == 4:             # <<<<<<<<<<<<<<
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis
 *     result = nearest_neighbors_nos
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_nearest_neighbors_nos); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 == 4);
  if (__pyx_t_2) {
 2296:         return nearest_neighbors_nos,  periodicity, periodicity_axis
    /* "water_algorithm_cython.pyx":2296
 * def add_dangling_bonds_to_nearest_neighbors(molecule_no,  nearest_neighbors_nos, periodicity, periodicity_axis):
 *     if len(nearest_neighbors_nos) == 4:
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis             # <<<<<<<<<<<<<<
 *     result = nearest_neighbors_nos
 *     while result.shape[0] < 4:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_nearest_neighbors_nos);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_nearest_neighbors_nos);
    __Pyx_GIVEREF(__pyx_v_nearest_neighbors_nos);
    __Pyx_INCREF(__pyx_v_periodicity);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_periodicity);
    __Pyx_GIVEREF(__pyx_v_periodicity);
    __Pyx_INCREF(__pyx_v_periodicity_axis);
    PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_periodicity_axis);
    __Pyx_GIVEREF(__pyx_v_periodicity_axis);
    __pyx_r = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;
 2297:     result = nearest_neighbors_nos
  /* "water_algorithm_cython.pyx":2297
 *     if len(nearest_neighbors_nos) == 4:
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis
 *     result = nearest_neighbors_nos             # <<<<<<<<<<<<<<
 *     while result.shape[0] < 4:
 *         result = np.append(result, molecule_no)
 */
  __Pyx_INCREF(__pyx_v_nearest_neighbors_nos);
  __pyx_v_result = __pyx_v_nearest_neighbors_nos;
 2298:     while result.shape[0] < 4:
  /* "water_algorithm_cython.pyx":2298
 *         return nearest_neighbors_nos,  periodicity, periodicity_axis
 *     result = nearest_neighbors_nos
 *     while result.shape[0] < 4:             # <<<<<<<<<<<<<<
 *         result = np.append(result, molecule_no)
 *         periodicity = np.append(periodicity, False)
 */
  while (1) {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s__shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_int_4, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!__pyx_t_2) break;
 2299:         result = np.append(result, molecule_no)
    /* "water_algorithm_cython.pyx":2299
 *     result = nearest_neighbors_nos
 *     while result.shape[0] < 4:
 *         result = np.append(result, molecule_no)             # <<<<<<<<<<<<<<
 *         periodicity = np.append(periodicity, False)
 *         periodicity_axis = np.append(periodicity_axis, 13)
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__append); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_result);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_result);
    __Pyx_GIVEREF(__pyx_v_result);
    __Pyx_INCREF(__pyx_v_molecule_no);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_molecule_no);
    __Pyx_GIVEREF(__pyx_v_molecule_no);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_result);
    __pyx_v_result = __pyx_t_5;
    __pyx_t_5 = 0;
 2300:         periodicity = np.append(periodicity, False)
    /* "water_algorithm_cython.pyx":2300
 *     while result.shape[0] < 4:
 *         result = np.append(result, molecule_no)
 *         periodicity = np.append(periodicity, False)             # <<<<<<<<<<<<<<
 *         periodicity_axis = np.append(periodicity_axis, 13)
 *     return result,  periodicity, periodicity_axis
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__append); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_periodicity);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_periodicity);
    __Pyx_GIVEREF(__pyx_v_periodicity);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_periodicity);
    __pyx_v_periodicity = __pyx_t_5;
    __pyx_t_5 = 0;
 2301:         periodicity_axis = np.append(periodicity_axis, 13)
    /* "water_algorithm_cython.pyx":2301
 *         result = np.append(result, molecule_no)
 *         periodicity = np.append(periodicity, False)
 *         periodicity_axis = np.append(periodicity_axis, 13)             # <<<<<<<<<<<<<<
 *     return result,  periodicity, periodicity_axis
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s__append); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_periodicity_axis);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_periodicity_axis);
    __Pyx_GIVEREF(__pyx_v_periodicity_axis);
    __Pyx_INCREF(__pyx_int_13);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_13);
    __Pyx_GIVEREF(__pyx_int_13);
    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_v_periodicity_axis);
    __pyx_v_periodicity_axis = __pyx_t_3;
    __pyx_t_3 = 0;
  }
 2302:     return result,  periodicity, periodicity_axis
  /* "water_algorithm_cython.pyx":2302
 *         periodicity = np.append(periodicity, False)
 *         periodicity_axis = np.append(periodicity_axis, 13)
 *     return result,  periodicity, periodicity_axis             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_result);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __Pyx_INCREF(__pyx_v_periodicity);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_periodicity);
  __Pyx_GIVEREF(__pyx_v_periodicity);
  __Pyx_INCREF(__pyx_v_periodicity_axis);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_periodicity_axis);
  __Pyx_GIVEREF(__pyx_v_periodicity_axis);
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("water_algorithm_cython.add_dangling_bonds_to_nearest_neighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_periodicity);
  __Pyx_XDECREF(__pyx_v_periodicity_axis);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2303: 
 2304: 
 2305: cdef list add_periodic_neighbors(p1, p2, cell, min_distance, max_distance, p2_number, result, periodicities, periodicity_axis, count, sortlist):
/* "water_algorithm_cython.pyx":2305
 * 
 * 
 * cdef list add_periodic_neighbors(p1, p2, cell, min_distance, max_distance, p2_number, result, periodicities, periodicity_axis, count, sortlist):             # <<<<<<<<<<<<<<
 *     distances, axis = get_periodic_distances(p1, p2, cell)
 *     cdef np.ndarray[DTYPE2_t, ndim=1] vec
 */

static PyObject *__pyx_f_22water_algorithm_cython_add_periodic_neighbors(PyObject *__pyx_v_p1, PyObject *__pyx_v_p2, PyObject *__pyx_v_cell, PyObject *__pyx_v_min_distance, PyObject *__pyx_v_max_distance, PyObject *__pyx_v_p2_number, PyObject *__pyx_v_result, PyObject *__pyx_v_periodicities, PyObject *__pyx_v_periodicity_axis, PyObject *__pyx_v_count, PyObject *__pyx_v_sortlist) {
  PyObject *__pyx_v_distances = NULL;
  PyObject *__pyx_v_axis = NULL;
  PyArrayObject *__pyx_v_vec = 0;
  PyObject *__pyx_v_distance = NULL;
  PyObject *__pyx_v_p_ax = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_vec;
  __Pyx_Buffer __pyx_pybuffer_vec;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_periodic_neighbors", 0);
  __Pyx_INCREF(__pyx_v_result);
  __Pyx_INCREF(__pyx_v_periodicities);
  __Pyx_INCREF(__pyx_v_count);
  __Pyx_INCREF(__pyx_v_sortlist);
  __pyx_pybuffer_vec.pybuffer.buf = NULL;
  __pyx_pybuffer_vec.refcount = 0;
  __pyx_pybuffernd_vec.data = NULL;
  __pyx_pybuffernd_vec.rcbuffer = &__pyx_pybuffer_vec;
 2306:     distances, axis = get_periodic_distances(p1, p2, cell)
  /* "water_algorithm_cython.pyx":2306
 * 
 * cdef list add_periodic_neighbors(p1, p2, cell, min_distance, max_distance, p2_number, result, periodicities, periodicity_axis, count, sortlist):
 *     distances, axis = get_periodic_distances(p1, p2, cell)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE2_t, ndim=1] vec
 *     for distance, p_ax in zip(distances, axis):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_140); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_p1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_p1);
  __Pyx_GIVEREF(__pyx_v_p1);
  __Pyx_INCREF(__pyx_v_p2);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_p2);
  __Pyx_GIVEREF(__pyx_v_p2);
  __Pyx_INCREF(__pyx_v_cell);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_cell);
  __Pyx_GIVEREF(__pyx_v_cell);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_distances = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_v_axis = __pyx_t_1;
  __pyx_t_1 = 0;
 2307:     cdef np.ndarray[DTYPE2_t, ndim=1] vec
 2308:     for distance, p_ax in zip(distances, axis):
  /* "water_algorithm_cython.pyx":2308
 *     distances, axis = get_periodic_distances(p1, p2, cell)
 *     cdef np.ndarray[DTYPE2_t, ndim=1] vec
 *     for distance, p_ax in zip(distances, axis):             # <<<<<<<<<<<<<<
 *         if distance > min_distance and distance < max_distance and p_ax != 13:
 *             result = np.append(result, p2_number)
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_distances);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_distances);
  __Pyx_GIVEREF(__pyx_v_distances);
  __Pyx_INCREF(__pyx_v_axis);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_axis);
  __Pyx_GIVEREF(__pyx_v_axis);
  __pyx_t_1 = PyObject_Call(__pyx_builtin_zip, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_7(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
      PyObject* sequence = __pyx_t_1;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_2);
      index = 1; __pyx_t_4 = __pyx_t_5(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_5 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_5 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L8_unpacking_done:;
    }
    __Pyx_XDECREF(__pyx_v_distance);
    __pyx_v_distance = __pyx_t_2;
    __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_v_p_ax);
    __pyx_v_p_ax = __pyx_t_4;
    __pyx_t_4 = 0;
 2309:         if distance > min_distance and distance < max_distance and p_ax != 13:
    /* "water_algorithm_cython.pyx":2309
 *     cdef np.ndarray[DTYPE2_t, ndim=1] vec
 *     for distance, p_ax in zip(distances, axis):
 *         if distance > min_distance and distance < max_distance and p_ax != 13:             # <<<<<<<<<<<<<<
 *             result = np.append(result, p2_number)
 *             periodicities = np.append(periodicities, True)
 */
    __pyx_t_1 = PyObject_RichCompare(__pyx_v_distance, __pyx_v_min_distance, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_9) {
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_distance, __pyx_v_max_distance, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_10) {
        __pyx_t_1 = PyObject_RichCompare(__pyx_v_p_ax, __pyx_int_13, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = __pyx_t_11;
      } else {
        __pyx_t_12 = __pyx_t_10;
      }
      __pyx_t_10 = __pyx_t_12;
    } else {
      __pyx_t_10 = __pyx_t_9;
    }
    if (__pyx_t_10) {
 2310:             result = np.append(result, p2_number)
      /* "water_algorithm_cython.pyx":2310
 *     for distance, p_ax in zip(distances, axis):
 *         if distance > min_distance and distance < max_distance and p_ax != 13:
 *             result = np.append(result, p2_number)             # <<<<<<<<<<<<<<
 *             periodicities = np.append(periodicities, True)
 *             periodicity_axis.append(p_ax)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__append); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_result);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_result);
      __Pyx_GIVEREF(__pyx_v_result);
      __Pyx_INCREF(__pyx_v_p2_number);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_p2_number);
      __Pyx_GIVEREF(__pyx_v_p2_number);
      __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_result);
      __pyx_v_result = __pyx_t_2;
      __pyx_t_2 = 0;
 2311:             periodicities = np.append(periodicities, True)
      /* "water_algorithm_cython.pyx":2311
 *         if distance > min_distance and distance < max_distance and p_ax != 13:
 *             result = np.append(result, p2_number)
 *             periodicities = np.append(periodicities, True)             # <<<<<<<<<<<<<<
 *             periodicity_axis.append(p_ax)
 *             vec = get_vector_from_periodicity_axis_number(p_ax)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__append); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_periodicities);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_periodicities);
      __Pyx_GIVEREF(__pyx_v_periodicities);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_v_periodicities);
      __pyx_v_periodicities = __pyx_t_2;
      __pyx_t_2 = 0;
 2312:             periodicity_axis.append(p_ax)
      /* "water_algorithm_cython.pyx":2312
 *             result = np.append(result, p2_number)
 *             periodicities = np.append(periodicities, True)
 *             periodicity_axis.append(p_ax)             # <<<<<<<<<<<<<<
 *             vec = get_vector_from_periodicity_axis_number(p_ax)
 *             sortlist = np.vstack((sortlist,  p2+vec*cell))
 */
      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_v_periodicity_axis, __pyx_v_p_ax); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 2313:             vec = get_vector_from_periodicity_axis_number(p_ax)
      /* "water_algorithm_cython.pyx":2313
 *             periodicities = np.append(periodicities, True)
 *             periodicity_axis.append(p_ax)
 *             vec = get_vector_from_periodicity_axis_number(p_ax)             # <<<<<<<<<<<<<<
 *             sortlist = np.vstack((sortlist,  p2+vec*cell))
 *             count += 1
 */
      __pyx_t_13 = __Pyx_PyInt_from_py_npy_uint8(__pyx_v_p_ax); if (unlikely((__pyx_t_13 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = ((PyObject *)__pyx_f_22water_algorithm_cython_get_vector_from_periodicity_axis_number(__pyx_t_13)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vec.rcbuffer->pybuffer);
        __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vec.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_2), &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_14 < 0)) {
          PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_vec.rcbuffer->pybuffer, (PyObject*)__pyx_v_vec, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          }
        }
        __pyx_pybuffernd_vec.diminfo[0].strides = __pyx_pybuffernd_vec.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_vec.diminfo[0].shape = __pyx_pybuffernd_vec.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __Pyx_XDECREF(((PyObject *)__pyx_v_vec));
      __pyx_v_vec = ((PyArrayObject *)__pyx_t_2);
      __pyx_t_2 = 0;
 2314:             sortlist = np.vstack((sortlist,  p2+vec*cell))
      /* "water_algorithm_cython.pyx":2314
 *             periodicity_axis.append(p_ax)
 *             vec = get_vector_from_periodicity_axis_number(p_ax)
 *             sortlist = np.vstack((sortlist,  p2+vec*cell))             # <<<<<<<<<<<<<<
 *             count += 1
 *     return [result, periodicities, periodicity_axis, count, sortlist]
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s__vstack); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_v_vec), __pyx_v_cell); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyNumber_Add(__pyx_v_p2, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_sortlist);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_sortlist);
      __Pyx_GIVEREF(__pyx_v_sortlist);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_sortlist);
      __pyx_v_sortlist = __pyx_t_2;
      __pyx_t_2 = 0;
 2315:             count += 1
      /* "water_algorithm_cython.pyx":2315
 *             vec = get_vector_from_periodicity_axis_number(p_ax)
 *             sortlist = np.vstack((sortlist,  p2+vec*cell))
 *             count += 1             # <<<<<<<<<<<<<<
 *     return [result, periodicities, periodicity_axis, count, sortlist]
 * 
 */
      __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_count, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_v_count);
      __pyx_v_count = __pyx_t_2;
      __pyx_t_2 = 0;
      goto __pyx_L9;
    }
    __pyx_L9:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2316:     return [result, periodicities, periodicity_axis, count, sortlist]
  /* "water_algorithm_cython.pyx":2316
 *             sortlist = np.vstack((sortlist,  p2+vec*cell))
 *             count += 1
 *     return [result, periodicities, periodicity_axis, count, sortlist]             # <<<<<<<<<<<<<<
 * 
 * cdef dict get_bond_variables_2(np.ndarray[DTYPE2_t, ndim=1] water_orientations, np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_3 = PyList_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_result);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_result);
  __Pyx_GIVEREF(__pyx_v_result);
  __Pyx_INCREF(__pyx_v_periodicities);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_periodicities);
  __Pyx_GIVEREF(__pyx_v_periodicities);
  __Pyx_INCREF(__pyx_v_periodicity_axis);
  PyList_SET_ITEM(__pyx_t_3, 2, __pyx_v_periodicity_axis);
  __Pyx_GIVEREF(__pyx_v_periodicity_axis);
  __Pyx_INCREF(__pyx_v_count);
  PyList_SET_ITEM(__pyx_t_3, 3, __pyx_v_count);
  __Pyx_GIVEREF(__pyx_v_count);
  __Pyx_INCREF(__pyx_v_sortlist);
  PyList_SET_ITEM(__pyx_t_3, 4, __pyx_v_sortlist);
  __Pyx_GIVEREF(__pyx_v_sortlist);
  __pyx_r = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vec.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.add_periodic_neighbors", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_vec.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_distances);
  __Pyx_XDECREF(__pyx_v_axis);
  __Pyx_XDECREF((PyObject *)__pyx_v_vec);
  __Pyx_XDECREF(__pyx_v_distance);
  __Pyx_XDECREF(__pyx_v_p_ax);
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF(__pyx_v_periodicities);
  __Pyx_XDECREF(__pyx_v_count);
  __Pyx_XDECREF(__pyx_v_sortlist);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2317: 
 2318: cdef dict get_bond_variables_2(np.ndarray[DTYPE2_t, ndim=1] water_orientations, np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):
/* "water_algorithm_cython.pyx":2318
 *     return [result, periodicities, periodicity_axis, count, sortlist]
 * 
 * cdef dict get_bond_variables_2(np.ndarray[DTYPE2_t, ndim=1] water_orientations, np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):             # <<<<<<<<<<<<<<
 *     cdef dict result = {}
 *     cdef unsigned char i, j
 */

static PyObject *__pyx_f_22water_algorithm_cython_get_bond_variables_2(PyArrayObject *__pyx_v_water_orientations, PyArrayObject *__pyx_v_nearest_neighbors_nos) {
  PyObject *__pyx_v_result = 0;
  unsigned char __pyx_v_i;
  unsigned char __pyx_v_j;
  signed char __pyx_v_periodic_axis;
  signed char __pyx_v_water_orientation;
  PyArrayObject *__pyx_v_nn = 0;
  __Pyx_memviewslice __pyx_v_bvv = { 0, 0, { 0 }, { 0 }, { 0 } };
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_neighbor_no;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nearest_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_nearest_neighbors_nos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nn;
  __Pyx_Buffer __pyx_pybuffer_nn;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_water_orientations;
  __Pyx_Buffer __pyx_pybuffer_water_orientations;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bond_variables_2", 0);
  __pyx_pybuffer_nn.pybuffer.buf = NULL;
  __pyx_pybuffer_nn.refcount = 0;
  __pyx_pybuffernd_nn.data = NULL;
  __pyx_pybuffernd_nn.rcbuffer = &__pyx_pybuffer_nn;
  __pyx_pybuffer_water_orientations.pybuffer.buf = NULL;
  __pyx_pybuffer_water_orientations.refcount = 0;
  __pyx_pybuffernd_water_orientations.data = NULL;
  __pyx_pybuffernd_water_orientations.rcbuffer = &__pyx_pybuffer_water_orientations;
  __pyx_pybuffer_nearest_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_nearest_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_nearest_neighbors_nos.data = NULL;
  __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer = &__pyx_pybuffer_nearest_neighbors_nos;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer, (PyObject*)__pyx_v_water_orientations, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_water_orientations.diminfo[0].strides = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_water_orientations.diminfo[0].shape = __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_v_nearest_neighbors_nos, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[2];
 2319:     cdef dict result = {}
  /* "water_algorithm_cython.pyx":2319
 * 
 * cdef dict get_bond_variables_2(np.ndarray[DTYPE2_t, ndim=1] water_orientations, np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):
 *     cdef dict result = {}             # <<<<<<<<<<<<<<
 *     cdef unsigned char i, j
 *     cdef signed char periodic_axis, water_orientation
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2320:     cdef unsigned char i, j
 2321:     cdef signed char periodic_axis, water_orientation
 2322:     cdef np.ndarray[DTYPE_t, ndim=1] nn
 2323:     cdef DTYPE2_t[::1] bvv
 2324:     cdef DTYPE_t neighbor_no
 2325:     for i,  nn in enumerate(nearest_neighbors_nos[0]):
  /* "water_algorithm_cython.pyx":2325
 *     cdef DTYPE2_t[::1] bvv
 *     cdef DTYPE_t neighbor_no
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):             # <<<<<<<<<<<<<<
 *         result[i] = {}
 *         water_orientation = water_orientations[i]
 */
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nearest_neighbors_nos), 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_v_nn, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_nn));
    __pyx_v_nn = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_i = __pyx_t_2;
    __pyx_t_2 = (__pyx_t_2 + 1);
 2326:         result[i] = {}
    /* "water_algorithm_cython.pyx":2326
 *     cdef DTYPE_t neighbor_no
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 *         result[i] = {}             # <<<<<<<<<<<<<<
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (__Pyx_SetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, ((PyObject *)__pyx_t_1), sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 2327:         water_orientation = water_orientations[i]
    /* "water_algorithm_cython.pyx":2327
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 *         result[i] = {}
 *         water_orientation = water_orientations[i]             # <<<<<<<<<<<<<<
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for j,  neighbor_no in enumerate(nn):
 */
    __pyx_t_11 = __pyx_v_i;
    __pyx_v_water_orientation = (*__Pyx_BufPtrStrided1d(__pyx_t_22water_algorithm_cython_DTYPE2_t *, __pyx_pybuffernd_water_orientations.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_water_orientations.diminfo[0].strides));
 2328:         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
    /* "water_algorithm_cython.pyx":2328
 *         result[i] = {}
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         for j,  neighbor_no in enumerate(nn):
 *             if neighbor_no not in result[i]:
 */
    __pyx_t_12 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_water_orientation); if (unlikely(!__pyx_t_12.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
    __pyx_v_bvv = __pyx_t_12;
    __pyx_t_12.memview = NULL;
    __pyx_t_12.data = NULL;
 2329:         for j,  neighbor_no in enumerate(nn):
    /* "water_algorithm_cython.pyx":2329
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for j,  neighbor_no in enumerate(nn):             # <<<<<<<<<<<<<<
 *             if neighbor_no not in result[i]:
 *                 result[i][neighbor_no] = {}
 */
    __pyx_t_13 = 0;
    if (PyList_CheckExact(((PyObject *)__pyx_v_nn)) || PyTuple_CheckExact(((PyObject *)__pyx_v_nn))) {
      __pyx_t_1 = ((PyObject *)__pyx_v_nn); __Pyx_INCREF(__pyx_t_1); __pyx_t_14 = 0;
      __pyx_t_15 = NULL;
    } else {
      __pyx_t_14 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_nn)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_15 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_15 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_14 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_16 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_16); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_16 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_15 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_14 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_16 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_14); __Pyx_INCREF(__pyx_t_16); __pyx_t_14++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_16 = PySequence_ITEM(__pyx_t_1, __pyx_t_14); __pyx_t_14++; if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_16 = __pyx_t_15(__pyx_t_1);
        if (unlikely(!__pyx_t_16)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_16);
      }
      __pyx_t_17 = __Pyx_PyInt_from_py_npy_uint8(__pyx_t_16); if (unlikely((__pyx_t_17 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_v_neighbor_no = __pyx_t_17;
      __pyx_v_j = __pyx_t_13;
      __pyx_t_13 = (__pyx_t_13 + 1);
 2330:             if neighbor_no not in result[i]:
      /* "water_algorithm_cython.pyx":2330
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for j,  neighbor_no in enumerate(nn):
 *             if neighbor_no not in result[i]:             # <<<<<<<<<<<<<<
 *                 result[i][neighbor_no] = {}
 *             periodic_axis = nearest_neighbors_nos[2][i][j]
 */
      __pyx_t_16 = __Pyx_PyInt_to_py_npy_uint8(__pyx_v_neighbor_no); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_18 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_19 = (__Pyx_PySequence_Contains(__pyx_t_16, __pyx_t_18, Py_NE)); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (__pyx_t_19) {
 2331:                 result[i][neighbor_no] = {}
        /* "water_algorithm_cython.pyx":2331
 *         for j,  neighbor_no in enumerate(nn):
 *             if neighbor_no not in result[i]:
 *                 result[i][neighbor_no] = {}             # <<<<<<<<<<<<<<
 *             periodic_axis = nearest_neighbors_nos[2][i][j]
 *             assert periodic_axis not in result[i][neighbor_no]
 */
        __pyx_t_18 = PyDict_New(); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_18));
        __pyx_t_16 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_16);
        if (__Pyx_SetItemInt(__pyx_t_16, __pyx_v_neighbor_no, ((PyObject *)__pyx_t_18), sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
        goto __pyx_L7;
      }
      __pyx_L7:;
 2332:             periodic_axis = nearest_neighbors_nos[2][i][j]
      /* "water_algorithm_cython.pyx":2332
 *             if neighbor_no not in result[i]:
 *                 result[i][neighbor_no] = {}
 *             periodic_axis = nearest_neighbors_nos[2][i][j]             # <<<<<<<<<<<<<<
 *             assert periodic_axis not in result[i][neighbor_no]
 *             result[i][neighbor_no][periodic_axis] = bvv[j]
 */
      __pyx_t_18 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nearest_neighbors_nos), 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_18, __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_t_18 = __Pyx_GetItemInt(__pyx_t_16, __pyx_v_j, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_20 = __Pyx_PyInt_AsSignedChar(__pyx_t_18); if (unlikely((__pyx_t_20 == (signed char)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_v_periodic_axis = __pyx_t_20;
 2333:             assert periodic_axis not in result[i][neighbor_no]
      /* "water_algorithm_cython.pyx":2333
 *                 result[i][neighbor_no] = {}
 *             periodic_axis = nearest_neighbors_nos[2][i][j]
 *             assert periodic_axis not in result[i][neighbor_no]             # <<<<<<<<<<<<<<
 *             result[i][neighbor_no][periodic_axis] = bvv[j]
 *     return result
 */
      #ifndef CYTHON_WITHOUT_ASSERTIONS
      __pyx_t_18 = PyInt_FromLong(__pyx_v_periodic_axis); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_16 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_21 = __Pyx_GetItemInt(__pyx_t_16, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_21) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_19 = (__Pyx_PySequence_Contains(__pyx_t_18, __pyx_t_21, Py_NE)); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      if (unlikely(!__pyx_t_19)) {
        PyErr_SetNone(PyExc_AssertionError);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #endif
 2334:             result[i][neighbor_no][periodic_axis] = bvv[j]
      /* "water_algorithm_cython.pyx":2334
 *             periodic_axis = nearest_neighbors_nos[2][i][j]
 *             assert periodic_axis not in result[i][neighbor_no]
 *             result[i][neighbor_no][periodic_axis] = bvv[j]             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
      __pyx_t_22 = __pyx_v_j;
      __pyx_t_21 = __Pyx_PyInt_to_py_npy_int8((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_22)) )))); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_18 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_18, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (__Pyx_SetItemInt(__pyx_t_16, __pyx_v_periodic_axis, __pyx_t_21, sizeof(signed char), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2335:     return result
  /* "water_algorithm_cython.pyx":2335
 *             assert periodic_axis not in result[i][neighbor_no]
 *             result[i][neighbor_no][periodic_axis] = bvv[j]
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef dict get_index_conversion_table(np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_21);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.get_bond_variables_2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_water_orientations.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2336: 
 2337: cdef dict get_index_conversion_table(np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):
/* "water_algorithm_cython.pyx":2337
 *     return result
 * 
 * cdef dict get_index_conversion_table(np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):             # <<<<<<<<<<<<<<
 *     cdef dict result = {}
 *     cdef unsigned char i, j
 */

static PyObject *__pyx_f_22water_algorithm_cython_get_index_conversion_table(PyArrayObject *__pyx_v_nearest_neighbors_nos) {
  PyObject *__pyx_v_result = 0;
  unsigned char __pyx_v_i;
  unsigned char __pyx_v_j;
  signed char __pyx_v_periodic_axis;
  PyArrayObject *__pyx_v_nn = 0;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_neighbor_no;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nearest_neighbors_nos;
  __Pyx_Buffer __pyx_pybuffer_nearest_neighbors_nos;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_nn;
  __Pyx_Buffer __pyx_pybuffer_nn;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_index_conversion_table", 0);
  __pyx_pybuffer_nn.pybuffer.buf = NULL;
  __pyx_pybuffer_nn.refcount = 0;
  __pyx_pybuffernd_nn.data = NULL;
  __pyx_pybuffernd_nn.rcbuffer = &__pyx_pybuffer_nn;
  __pyx_pybuffer_nearest_neighbors_nos.pybuffer.buf = NULL;
  __pyx_pybuffer_nearest_neighbors_nos.refcount = 0;
  __pyx_pybuffernd_nearest_neighbors_nos.data = NULL;
  __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer = &__pyx_pybuffer_nearest_neighbors_nos;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer, (PyObject*)__pyx_v_nearest_neighbors_nos, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].shape = __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.shape[2];
 2338:     cdef dict result = {}
  /* "water_algorithm_cython.pyx":2338
 * 
 * cdef dict get_index_conversion_table(np.ndarray[DTYPE_t, ndim=3]  nearest_neighbors_nos):
 *     cdef dict result = {}             # <<<<<<<<<<<<<<
 *     cdef unsigned char i, j
 *     cdef signed char periodic_axis, water_orientation
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_v_result = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2339:     cdef unsigned char i, j
 2340:     cdef signed char periodic_axis, water_orientation
 2341:     cdef np.ndarray[DTYPE_t, ndim=1] nn
 2342:     cdef DTYPE_t neighbor_no
 2343: 
 2344:     for i,  nn in enumerate(nearest_neighbors_nos[0]):
  /* "water_algorithm_cython.pyx":2344
 *     cdef DTYPE_t neighbor_no
 * 
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):             # <<<<<<<<<<<<<<
 *         result[i] = {}
 *         for j,  neighbor_no in enumerate(nn):
 */
  __pyx_t_2 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_nearest_neighbors_nos), 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_3)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_1)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_nn.rcbuffer->pybuffer, (PyObject*)__pyx_v_nn, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_nn.diminfo[0].strides = __pyx_pybuffernd_nn.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_nn.diminfo[0].shape = __pyx_pybuffernd_nn.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_6 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_nn));
    __pyx_v_nn = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_i = __pyx_t_2;
    __pyx_t_2 = (__pyx_t_2 + 1);
 2345:         result[i] = {}
    /* "water_algorithm_cython.pyx":2345
 * 
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 *         result[i] = {}             # <<<<<<<<<<<<<<
 *         for j,  neighbor_no in enumerate(nn):
 *             if neighbor_no not in result[i]:
 */
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    if (__Pyx_SetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, ((PyObject *)__pyx_t_1), sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 2346:         for j,  neighbor_no in enumerate(nn):
    /* "water_algorithm_cython.pyx":2346
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 *         result[i] = {}
 *         for j,  neighbor_no in enumerate(nn):             # <<<<<<<<<<<<<<
 *             if neighbor_no not in result[i]:
 *                 result[i][neighbor_no] = {}
 */
    __pyx_t_11 = 0;
    if (PyList_CheckExact(((PyObject *)__pyx_v_nn)) || PyTuple_CheckExact(((PyObject *)__pyx_v_nn))) {
      __pyx_t_1 = ((PyObject *)__pyx_v_nn); __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_nn)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_1)) {
        if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_14 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_14); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_14 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_1)) {
        if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_14); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_14 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_14 = __pyx_t_13(__pyx_t_1);
        if (unlikely(!__pyx_t_14)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_14);
      }
      __pyx_t_15 = __Pyx_PyInt_from_py_npy_uint8(__pyx_t_14); if (unlikely((__pyx_t_15 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_v_neighbor_no = __pyx_t_15;
      __pyx_v_j = __pyx_t_11;
      __pyx_t_11 = (__pyx_t_11 + 1);
 2347:             if neighbor_no not in result[i]:
      /* "water_algorithm_cython.pyx":2347
 *         result[i] = {}
 *         for j,  neighbor_no in enumerate(nn):
 *             if neighbor_no not in result[i]:             # <<<<<<<<<<<<<<
 *                 result[i][neighbor_no] = {}
 *             periodic_axis = nearest_neighbors_nos[2, i, j]
 */
      __pyx_t_14 = __Pyx_PyInt_to_py_npy_uint8(__pyx_v_neighbor_no); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_16 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_16) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_17 = (__Pyx_PySequence_Contains(__pyx_t_14, __pyx_t_16, Py_NE)); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      if (__pyx_t_17) {
 2348:                 result[i][neighbor_no] = {}
        /* "water_algorithm_cython.pyx":2348
 *         for j,  neighbor_no in enumerate(nn):
 *             if neighbor_no not in result[i]:
 *                 result[i][neighbor_no] = {}             # <<<<<<<<<<<<<<
 *             periodic_axis = nearest_neighbors_nos[2, i, j]
 * 
 */
        __pyx_t_16 = PyDict_New(); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_16));
        __pyx_t_14 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_14) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_14);
        if (__Pyx_SetItemInt(__pyx_t_14, __pyx_v_neighbor_no, ((PyObject *)__pyx_t_16), sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_16)); __pyx_t_16 = 0;
        goto __pyx_L7;
      }
      __pyx_L7:;
 2349:             periodic_axis = nearest_neighbors_nos[2, i, j]
      /* "water_algorithm_cython.pyx":2349
 *             if neighbor_no not in result[i]:
 *                 result[i][neighbor_no] = {}
 *             periodic_axis = nearest_neighbors_nos[2, i, j]             # <<<<<<<<<<<<<<
 * 
 *             #assert periodic_axis not in result[i][neighbor_no]
 */
      __pyx_t_18 = 2;
      __pyx_t_19 = __pyx_v_i;
      __pyx_t_20 = __pyx_v_j;
      __pyx_v_periodic_axis = (*__Pyx_BufPtrStrided3d(__pyx_t_22water_algorithm_cython_DTYPE_t *, __pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[1].strides, __pyx_t_20, __pyx_pybuffernd_nearest_neighbors_nos.diminfo[2].strides));
 2350: 
 2351:             #assert periodic_axis not in result[i][neighbor_no]
 2352:             result[i][neighbor_no][periodic_axis] = np.array([i, j], dtype=DTYPE)
      /* "water_algorithm_cython.pyx":2352
 * 
 *             #assert periodic_axis not in result[i][neighbor_no]
 *             result[i][neighbor_no][periodic_axis] = np.array([i, j], dtype=DTYPE)             # <<<<<<<<<<<<<<
 *     return result
 * 
 */
      __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s__array); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_21 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_22 = PyList_New(2); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_22);
      PyList_SET_ITEM(__pyx_t_22, 0, __pyx_t_16);
      __Pyx_GIVEREF(__pyx_t_16);
      PyList_SET_ITEM(__pyx_t_22, 1, __pyx_t_21);
      __Pyx_GIVEREF(__pyx_t_21);
      __pyx_t_16 = 0;
      __pyx_t_21 = 0;
      __pyx_t_21 = PyTuple_New(1); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      PyTuple_SET_ITEM(__pyx_t_21, 0, ((PyObject *)__pyx_t_22));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_22));
      __pyx_t_22 = 0;
      __pyx_t_22 = PyDict_New(); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_22));
      __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      if (PyDict_SetItem(__pyx_t_22, ((PyObject *)__pyx_n_s__dtype), __pyx_t_16) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_21), ((PyObject *)__pyx_t_22)); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_22)); __pyx_t_22 = 0;
      __pyx_t_22 = __Pyx_GetItemInt(((PyObject *)__pyx_v_result), __pyx_v_i, sizeof(unsigned char)+1, PyInt_FromLong, 0, 0, 0); if (!__pyx_t_22) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_22);
      __pyx_t_21 = __Pyx_GetItemInt(__pyx_t_22, __pyx_v_neighbor_no, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_21) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      if (__Pyx_SetItemInt(__pyx_t_21, __pyx_v_periodic_axis, __pyx_t_16, sizeof(signed char), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 2353:     return result
  /* "water_algorithm_cython.pyx":2353
 *             #assert periodic_axis not in result[i][neighbor_no]
 *             result[i][neighbor_no][periodic_axis] = np.array([i, j], dtype=DTYPE)
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef inline void get_bond_variables_3(DTYPE2_t[::1] water_orientations, DTYPE_t[:, :, ::1]  nearest_neighbors_nos, int N, DTYPE2_t[:, ::1] bond_variables):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = __pyx_v_result;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.get_index_conversion_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nearest_neighbors_nos.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_nn.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_result);
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2354: 
 2355: cdef inline void get_bond_variables_3(DTYPE2_t[::1] water_orientations, DTYPE_t[:, :, ::1]  nearest_neighbors_nos, int N, DTYPE2_t[:, ::1] bond_variables):
/* "water_algorithm_cython.pyx":2355
 *     return result
 * 
 * cdef inline void get_bond_variables_3(DTYPE2_t[::1] water_orientations, DTYPE_t[:, :, ::1]  nearest_neighbors_nos, int N, DTYPE2_t[:, ::1] bond_variables):             # <<<<<<<<<<<<<<
 *     cdef unsigned char i
 *     cdef DTYPE2_t periodic_axis, water_orientation
 */

static CYTHON_INLINE void __pyx_f_22water_algorithm_cython_get_bond_variables_3(__Pyx_memviewslice __pyx_v_water_orientations, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_nearest_neighbors_nos, int __pyx_v_N, __Pyx_memviewslice __pyx_v_bond_variables) {
  unsigned char __pyx_v_i;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_water_orientation;
  __Pyx_memviewslice __pyx_v_bvv = { 0, 0, { 0 }, { 0 }, { 0 } };
  long __pyx_v_j;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bond_variables_3", 0);
 2356:     cdef unsigned char i
 2357:     cdef DTYPE2_t periodic_axis, water_orientation
 2358:     cdef DTYPE_t neighbor_no
 2359:     cdef DTYPE2_t[::1] bvv
 2360:     for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":2360
 *     cdef DTYPE_t neighbor_no
 *     cdef DTYPE2_t[::1] bvv
 *     for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 */
  __pyx_t_1 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {
 2361:         water_orientation = water_orientations[i]
    /* "water_algorithm_cython.pyx":2361
 *     cdef DTYPE2_t[::1] bvv
 *     for i from 0 <= i < N:
 *         water_orientation = water_orientations[i]             # <<<<<<<<<<<<<<
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for j from 0 <= j < 4:
 */
    __pyx_t_2 = __pyx_v_i;
    __pyx_v_water_orientation = (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_water_orientations.data) + __pyx_t_2)) )));
 2362:         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
    /* "water_algorithm_cython.pyx":2362
 *     for i from 0 <= i < N:
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         for j from 0 <= j < 4:
 *             bond_variables[i, j] = bvv[j]
 */
    __pyx_t_3 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_v_water_orientation); if (unlikely(!__pyx_t_3.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
    __pyx_v_bvv = __pyx_t_3;
    __pyx_t_3.memview = NULL;
    __pyx_t_3.data = NULL;
 2363:         for j from 0 <= j < 4:
    /* "water_algorithm_cython.pyx":2363
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for j from 0 <= j < 4:             # <<<<<<<<<<<<<<
 *             bond_variables[i, j] = bvv[j]
 * 
 */
    for (__pyx_v_j = 0; __pyx_v_j < 4; __pyx_v_j++) {
 2364:             bond_variables[i, j] = bvv[j]
      /* "water_algorithm_cython.pyx":2364
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for j from 0 <= j < 4:
 *             bond_variables[i, j] = bvv[j]             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_4 = __pyx_v_j;
      __pyx_t_5 = __pyx_v_i;
      __pyx_t_6 = __pyx_v_j;
      *((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=1 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ (__pyx_v_bond_variables.data + __pyx_t_5 * __pyx_v_bond_variables.strides[0]) )) + __pyx_t_6)) )) = (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_bvv.data) + __pyx_t_4)) )));
    }
  }

  goto __pyx_L0;
  __pyx_L1_error:;
  __PYX_XDEC_MEMVIEW(&__pyx_t_3, 1);
  __Pyx_WriteUnraisable("water_algorithm_cython.get_bond_variables_3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bvv, 1);
  __Pyx_RefNannyFinishContext();
}
 2365: 
 2366: 
 2367: 
 2368: cdef  np.ndarray[DTYPE2_t, ndim=3] get_bond_variables(water_orientations, nearest_neighbors_nos):
/* "water_algorithm_cython.pyx":2368
 * 
 * 
 * cdef  np.ndarray[DTYPE2_t, ndim=3] get_bond_variables(water_orientations, nearest_neighbors_nos):             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE2_t, ndim=3] bond_variables = np.zeros((2, len(nearest_neighbors_nos[0]),  len(nearest_neighbors_nos[0])),  dtype='int8')
 *     cdef np.ndarray[DTYPE2_t, ndim=1] bvv
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_get_bond_variables(PyObject *__pyx_v_water_orientations, PyObject *__pyx_v_nearest_neighbors_nos) {
  PyArrayObject *__pyx_v_bond_variables = 0;
  PyArrayObject *__pyx_v_bvv = 0;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_nn = NULL;
  PyObject *__pyx_v_water_orientation = NULL;
  PyObject *__pyx_v_l = NULL;
  PyObject *__pyx_v_neighbor_no = NULL;
  PyObject *__pyx_v_periodic = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_bond_variables;
  __Pyx_Buffer __pyx_pybuffer_bond_variables;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_bvv;
  __Pyx_Buffer __pyx_pybuffer_bvv;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bond_variables", 0);
  __pyx_pybuffer_bond_variables.pybuffer.buf = NULL;
  __pyx_pybuffer_bond_variables.refcount = 0;
  __pyx_pybuffernd_bond_variables.data = NULL;
  __pyx_pybuffernd_bond_variables.rcbuffer = &__pyx_pybuffer_bond_variables;
  __pyx_pybuffer_bvv.pybuffer.buf = NULL;
  __pyx_pybuffer_bvv.refcount = 0;
  __pyx_pybuffernd_bvv.data = NULL;
  __pyx_pybuffernd_bvv.rcbuffer = &__pyx_pybuffer_bvv;
 2369:     cdef np.ndarray[DTYPE2_t, ndim=3] bond_variables = np.zeros((2, len(nearest_neighbors_nos[0]),  len(nearest_neighbors_nos[0])),  dtype='int8')
  /* "water_algorithm_cython.pyx":2369
 * 
 * cdef  np.ndarray[DTYPE2_t, ndim=3] get_bond_variables(water_orientations, nearest_neighbors_nos):
 *     cdef np.ndarray[DTYPE2_t, ndim=3] bond_variables = np.zeros((2, len(nearest_neighbors_nos[0]),  len(nearest_neighbors_nos[0])),  dtype='int8')             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[DTYPE2_t, ndim=1] bvv
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bond_variables.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_bond_variables = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_pybuffernd_bond_variables.diminfo[0].strides = __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bond_variables.diminfo[0].shape = __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_bond_variables.diminfo[1].strides = __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_bond_variables.diminfo[1].shape = __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_bond_variables.diminfo[2].strides = __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_bond_variables.diminfo[2].shape = __pyx_pybuffernd_bond_variables.rcbuffer->pybuffer.shape[2];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_bond_variables = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 2370:     cdef np.ndarray[DTYPE2_t, ndim=1] bvv
 2371:     for i,  nn in enumerate(nearest_neighbors_nos[0]):
  /* "water_algorithm_cython.pyx":2371
 *     cdef np.ndarray[DTYPE2_t, ndim=3] bond_variables = np.zeros((2, len(nearest_neighbors_nos[0]),  len(nearest_neighbors_nos[0])),  dtype='int8')
 *     cdef np.ndarray[DTYPE2_t, ndim=1] bvv
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):             # <<<<<<<<<<<<<<
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 0, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_4)) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_4)) {
      if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_4);
      if (unlikely(!__pyx_t_5)) {
        if (PyErr_Occurred()) {
          if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF(__pyx_v_nn);
    __pyx_v_nn = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF(__pyx_v_i);
    __pyx_v_i = __pyx_t_1;
    __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;
 2372:         water_orientation = water_orientations[i]
    /* "water_algorithm_cython.pyx":2372
 *     cdef np.ndarray[DTYPE2_t, ndim=1] bvv
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 *         water_orientation = water_orientations[i]             # <<<<<<<<<<<<<<
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for l,  neighbor_no in enumerate(nn):
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_water_orientations, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF(__pyx_v_water_orientation);
    __pyx_v_water_orientation = __pyx_t_5;
    __pyx_t_5 = 0;
 2373:         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
    /* "water_algorithm_cython.pyx":2373
 *     for i,  nn in enumerate(nearest_neighbors_nos[0]):
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)             # <<<<<<<<<<<<<<
 *         for l,  neighbor_no in enumerate(nn):
 *             periodic = nearest_neighbors_nos[1][i][l]
 */
    __pyx_t_8 = __Pyx_PyInt_from_py_npy_int8(__pyx_v_water_orientation); if (unlikely((__pyx_t_8 == (npy_int8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __pyx_f_22water_algorithm_cython_get_bond_variable_values_from_water_orientation(__pyx_t_8); if (unlikely(!__pyx_t_9.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, 0);; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    if (!(likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bvv.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bvv.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bvv.rcbuffer->pybuffer, (PyObject*)__pyx_v_bvv, &__Pyx_TypeInfo_nn___pyx_t_22water_algorithm_cython_DTYPE2_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
      }
      __pyx_pybuffernd_bvv.diminfo[0].strides = __pyx_pybuffernd_bvv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bvv.diminfo[0].shape = __pyx_pybuffernd_bvv.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = 0;
    __Pyx_XDECREF(((PyObject *)__pyx_v_bvv));
    __pyx_v_bvv = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;
 2374:         for l,  neighbor_no in enumerate(nn):
    /* "water_algorithm_cython.pyx":2374
 *         water_orientation = water_orientations[i]
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for l,  neighbor_no in enumerate(nn):             # <<<<<<<<<<<<<<
 *             periodic = nearest_neighbors_nos[1][i][l]
 *             if neighbor_no > i:
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_5 = __pyx_int_0;
    if (PyList_CheckExact(__pyx_v_nn) || PyTuple_CheckExact(__pyx_v_nn)) {
      __pyx_t_2 = __pyx_v_nn; __Pyx_INCREF(__pyx_t_2); __pyx_t_15 = 0;
      __pyx_t_16 = NULL;
    } else {
      __pyx_t_15 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_nn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_16 = Py_TYPE(__pyx_t_2)->tp_iternext;
    }
    for (;;) {
      if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_2)) {
        if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_17 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_15); __Pyx_INCREF(__pyx_t_17); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_17 = PySequence_ITEM(__pyx_t_2, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_2)) {
        if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_17 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_15); __Pyx_INCREF(__pyx_t_17); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_17 = PySequence_ITEM(__pyx_t_2, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_17 = __pyx_t_16(__pyx_t_2);
        if (unlikely(!__pyx_t_17)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_17);
      }
      __Pyx_XDECREF(__pyx_v_neighbor_no);
      __pyx_v_neighbor_no = __pyx_t_17;
      __pyx_t_17 = 0;
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XDECREF(__pyx_v_l);
      __pyx_v_l = __pyx_t_5;
      __pyx_t_17 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_5);
      __pyx_t_5 = __pyx_t_17;
      __pyx_t_17 = 0;
 2375:             periodic = nearest_neighbors_nos[1][i][l]
      /* "water_algorithm_cython.pyx":2375
 *         bvv = get_bond_variable_values_from_water_orientation(water_orientation)
 *         for l,  neighbor_no in enumerate(nn):
 *             periodic = nearest_neighbors_nos[1][i][l]             # <<<<<<<<<<<<<<
 *             if neighbor_no > i:
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 */
      __pyx_t_17 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 1, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = PyObject_GetItem(__pyx_t_17, __pyx_v_i); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = PyObject_GetItem(__pyx_t_18, __pyx_v_l); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_v_periodic);
      __pyx_v_periodic = __pyx_t_17;
      __pyx_t_17 = 0;
 2376:             if neighbor_no > i:
      /* "water_algorithm_cython.pyx":2376
 *         for l,  neighbor_no in enumerate(nn):
 *             periodic = nearest_neighbors_nos[1][i][l]
 *             if neighbor_no > i:             # <<<<<<<<<<<<<<
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 */
      __pyx_t_17 = PyObject_RichCompare(__pyx_v_neighbor_no, __pyx_v_i, Py_GT); __Pyx_XGOTREF(__pyx_t_17); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (__pyx_t_19) {
 2377:                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
        /* "water_algorithm_cython.pyx":2377
 *             periodic = nearest_neighbors_nos[1][i][l]
 *             if neighbor_no > i:
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]             # <<<<<<<<<<<<<<
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 *                 bond_variables[periodic][neighbor_no][i][0] = -bvv[l]
 */
        __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_bvv), __pyx_v_l); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_18 = PyObject_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_periodic); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_20 = PyObject_GetItem(__pyx_t_18, __pyx_v_i); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_GetItem(__pyx_t_20, __pyx_v_neighbor_no); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (__Pyx_SetItemInt(__pyx_t_18, 0, __pyx_t_17, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
 2378:                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
        /* "water_algorithm_cython.pyx":2378
 *             if neighbor_no > i:
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]             # <<<<<<<<<<<<<<
 *                 bond_variables[periodic][neighbor_no][i][0] = -bvv[l]
 *                 bond_variables[periodic][neighbor_no][i][1] = get_opposite_periodicity_axis_number(nearest_neighbors_nos[2][i][l])
 */
        __pyx_t_17 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_18 = PyObject_GetItem(__pyx_t_17, __pyx_v_i); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(__pyx_t_18, __pyx_v_l); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_periodic); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_20 = PyObject_GetItem(__pyx_t_18, __pyx_v_i); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_GetItem(__pyx_t_20, __pyx_v_neighbor_no); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (__Pyx_SetItemInt(__pyx_t_18, 1, __pyx_t_17, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
 2379:                 bond_variables[periodic][neighbor_no][i][0] = -bvv[l]
        /* "water_algorithm_cython.pyx":2379
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 *                 bond_variables[periodic][neighbor_no][i][0] = -bvv[l]             # <<<<<<<<<<<<<<
 *                 bond_variables[periodic][neighbor_no][i][1] = get_opposite_periodicity_axis_number(nearest_neighbors_nos[2][i][l])
 *             elif neighbor_no == i:
 */
        __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_bvv), __pyx_v_l); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_18 = PyNumber_Negative(__pyx_t_17); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_periodic); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_20 = PyObject_GetItem(__pyx_t_17, __pyx_v_neighbor_no); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(__pyx_t_20, __pyx_v_i); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (__Pyx_SetItemInt(__pyx_t_17, 0, __pyx_t_18, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
 2380:                 bond_variables[periodic][neighbor_no][i][1] = get_opposite_periodicity_axis_number(nearest_neighbors_nos[2][i][l])
        /* "water_algorithm_cython.pyx":2380
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 *                 bond_variables[periodic][neighbor_no][i][0] = -bvv[l]
 *                 bond_variables[periodic][neighbor_no][i][1] = get_opposite_periodicity_axis_number(nearest_neighbors_nos[2][i][l])             # <<<<<<<<<<<<<<
 *             elif neighbor_no == i:
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 */
        __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_17 = PyObject_GetItem(__pyx_t_18, __pyx_v_i); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_GetItem(__pyx_t_17, __pyx_v_l); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_21 = __Pyx_PyInt_from_py_npy_uint8(__pyx_t_18); if (unlikely((__pyx_t_21 == (npy_uint8)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = __Pyx_PyInt_to_py_npy_uint8(__pyx_f_22water_algorithm_cython_get_opposite_periodicity_axis_number(__pyx_t_21)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_periodic); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_20 = PyObject_GetItem(__pyx_t_17, __pyx_v_neighbor_no); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(__pyx_t_20, __pyx_v_i); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (__Pyx_SetItemInt(__pyx_t_17, 1, __pyx_t_18, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        goto __pyx_L7;
      }
 2381:             elif neighbor_no == i:
      /* "water_algorithm_cython.pyx":2381
 *                 bond_variables[periodic][neighbor_no][i][0] = -bvv[l]
 *                 bond_variables[periodic][neighbor_no][i][1] = get_opposite_periodicity_axis_number(nearest_neighbors_nos[2][i][l])
 *             elif neighbor_no == i:             # <<<<<<<<<<<<<<
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 */
      __pyx_t_18 = PyObject_RichCompare(__pyx_v_neighbor_no, __pyx_v_i, Py_EQ); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (__pyx_t_19) {
 2382:                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
        /* "water_algorithm_cython.pyx":2382
 *                 bond_variables[periodic][neighbor_no][i][1] = get_opposite_periodicity_axis_number(nearest_neighbors_nos[2][i][l])
 *             elif neighbor_no == i:
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]             # <<<<<<<<<<<<<<
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 *     return bond_variables
 */
        __pyx_t_18 = PyObject_GetItem(((PyObject *)__pyx_v_bvv), __pyx_v_l); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_periodic); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_20 = PyObject_GetItem(__pyx_t_17, __pyx_v_i); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(__pyx_t_20, __pyx_v_neighbor_no); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (__Pyx_SetItemInt(__pyx_t_17, 0, __pyx_t_18, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
 2383:                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
        /* "water_algorithm_cython.pyx":2383
 *             elif neighbor_no == i:
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]             # <<<<<<<<<<<<<<
 *     return bond_variables
 * 
 */
        __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_nearest_neighbors_nos, 2, sizeof(long), PyInt_FromLong, 0, 0, 0); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_17 = PyObject_GetItem(__pyx_t_18, __pyx_v_i); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_18 = PyObject_GetItem(__pyx_t_17, __pyx_v_l); if (!__pyx_t_18) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_bond_variables), __pyx_v_periodic); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_20 = PyObject_GetItem(__pyx_t_17, __pyx_v_i); if (!__pyx_t_20) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(__pyx_t_20, __pyx_v_neighbor_no); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        if (__Pyx_SetItemInt(__pyx_t_17, 1, __pyx_t_18, sizeof(long), PyInt_FromLong, 0, 0, 0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 2384:     return bond_variables
  /* "water_algorithm_cython.pyx":2384
 *                 bond_variables[periodic][i][neighbor_no][0] = bvv[l]
 *                 bond_variables[periodic][i][neighbor_no][1] = nearest_neighbors_nos[2][i][l]
 *     return bond_variables             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint wos_are_equal(DTYPE2_t[::1] orientation1, DTYPE2_t[::1] orientation2, int N):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_bond_variables));
  __pyx_r = ((PyArrayObject *)__pyx_v_bond_variables);
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bond_variables.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bvv.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("water_algorithm_cython.get_bond_variables", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bond_variables.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bvv.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_bond_variables);
  __Pyx_XDECREF((PyObject *)__pyx_v_bvv);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_nn);
  __Pyx_XDECREF(__pyx_v_water_orientation);
  __Pyx_XDECREF(__pyx_v_l);
  __Pyx_XDECREF(__pyx_v_neighbor_no);
  __Pyx_XDECREF(__pyx_v_periodic);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2385: 
 2386: cdef inline bint wos_are_equal(DTYPE2_t[::1] orientation1, DTYPE2_t[::1] orientation2, int N):
/* "water_algorithm_cython.pyx":2386
 *     return bond_variables
 * 
 * cdef inline bint wos_are_equal(DTYPE2_t[::1] orientation1, DTYPE2_t[::1] orientation2, int N):             # <<<<<<<<<<<<<<
 *     """
 *         Checks if two water orientation lists are equal
 */

static CYTHON_INLINE int __pyx_f_22water_algorithm_cython_wos_are_equal(__Pyx_memviewslice __pyx_v_orientation1, __Pyx_memviewslice __pyx_v_orientation2, int __pyx_v_N) {
  int __pyx_v_i;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("wos_are_equal", 0);
 2387:     """
 2388:         Checks if two water orientation lists are equal
 2389:         Parameter:
 2390:             orientation1 : first orientation list
 2391:             orientation2 : second orientation list
 2392:             N            : The number of molecules in raft
 2393:         Returns
 2394:             0 if are not equal
 2395:             1 if they are equal
 2396:     """
 2397:     cdef int i
 2398:     for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":2398
 *     """
 *     cdef int i
 *     for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *         if orientation1[i] != orientation2[i]:
 *             return 0
 */
  __pyx_t_1 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {
 2399:         if orientation1[i] != orientation2[i]:
    /* "water_algorithm_cython.pyx":2399
 *     cdef int i
 *     for i from 0 <= i < N:
 *         if orientation1[i] != orientation2[i]:             # <<<<<<<<<<<<<<
 *             return 0
 *     return 1
 */
    __pyx_t_2 = __pyx_v_i;
    __pyx_t_3 = __pyx_v_i;
    __pyx_t_4 = ((*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_orientation1.data) + __pyx_t_2)) ))) != (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_orientation2.data) + __pyx_t_3)) ))));
    if (__pyx_t_4) {
 2400:             return 0
      /* "water_algorithm_cython.pyx":2400
 *     for i from 0 <= i < N:
 *         if orientation1[i] != orientation2[i]:
 *             return 0             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
 2401:     return 1
  /* "water_algorithm_cython.pyx":2401
 *         if orientation1[i] != orientation2[i]:
 *             return 0
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef inline bint water_orientation_is_valid_using_possible_combinations(signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no, DTYPE_t [:, :, ::1] possible_combinations, DTYPE_t [::1] nn, bint init):
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2402: 
 2403: cdef inline bint water_orientation_is_valid_using_possible_combinations(signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no, DTYPE_t [:, :, ::1] possible_combinations, DTYPE_t [::1] nn, bint init):
/* "water_algorithm_cython.pyx":2403
 *     return 1
 * 
 * cdef inline bint water_orientation_is_valid_using_possible_combinations(signed char water_orientation, DTYPE2_t [::1] water_orient, unsigned char molecule_no, DTYPE_t [:, :, ::1] possible_combinations, DTYPE_t [::1] nn, bint init):             # <<<<<<<<<<<<<<
 *     """
 *        Checks if the ice rules are fulfilled for given water orientation for the current molecule (molecule_no)
 */

static CYTHON_INLINE int __pyx_f_22water_algorithm_cython_water_orientation_is_valid_using_possible_combinations(signed char __pyx_v_water_orientation, __Pyx_memviewslice __pyx_v_water_orient, CYTHON_UNUSED unsigned char __pyx_v_molecule_no, __Pyx_memviewslice __pyx_v_possible_combinations, __Pyx_memviewslice __pyx_v_nn, int __pyx_v_init) {
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_neighbor_no;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_i;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_combination_possible;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_N;
  __pyx_t_22water_algorithm_cython_DTYPE2_t __pyx_v_neighbor_orientation;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("water_orientation_is_valid_using_possible_combinations", 0);
 2404:     """
 2405:        Checks if the ice rules are fulfilled for given water orientation for the current molecule (molecule_no)
 2406:        in given water orientation environment water_orient. The process is done using the given possible combinations.
 2407:             Parameters:
 2408:                 water_orientation    : water orientation tried for current molecule
 2409:                 water_orient         : water orientation list that describes the water orientation environment
 2410:                 molecule_no          : the number of the molecule that is being handled
 2411:                 possible_combinations: the possible water orientation combinations for current molecule (molecule_no) and its neighbors
 2412:                 nn                   : nearest neighbors numbers for molecule handled (molecule_no)
 2413:     """
 2414:     cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]
  /* "water_algorithm_cython.pyx":2414
 *                 nn                   : nearest neighbors numbers for molecule handled (molecule_no)
 *     """
 *     cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]             # <<<<<<<<<<<<<<
 *     cdef DTYPE2_t neighbor_orientation
 *     if init:
 */
  __pyx_v_N = (__pyx_v_nn.shape[0]);
 2415:     cdef DTYPE2_t neighbor_orientation
 2416:     if init:
  /* "water_algorithm_cython.pyx":2416
 *     cdef DTYPE_t neighbor_no, i, combination_possible, N = nn.shape[0]
 *     cdef DTYPE2_t neighbor_orientation
 *     if init:             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < N:
 *             for neighbor_orientation from 0 <= neighbor_orientation < 6:
 */
  if (__pyx_v_init) {
 2417:         for i from 0 <= i < N:
    /* "water_algorithm_cython.pyx":2417
 *     cdef DTYPE2_t neighbor_orientation
 *     if init:
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             for neighbor_orientation from 0 <= neighbor_orientation < 6:
 *                 combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 */
    __pyx_t_1 = __pyx_v_N;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {
 2418:             for neighbor_orientation from 0 <= neighbor_orientation < 6:
      /* "water_algorithm_cython.pyx":2418
 *     if init:
 *         for i from 0 <= i < N:
 *             for neighbor_orientation from 0 <= neighbor_orientation < 6:             # <<<<<<<<<<<<<<
 *                 combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *                 if combination_possible:
 */
      for (__pyx_v_neighbor_orientation = 0; __pyx_v_neighbor_orientation < 6; __pyx_v_neighbor_orientation++) {
 2419:                 combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
        /* "water_algorithm_cython.pyx":2419
 *         for i from 0 <= i < N:
 *             for neighbor_orientation from 0 <= neighbor_orientation < 6:
 *                 combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]             # <<<<<<<<<<<<<<
 *                 if combination_possible:
 *                     return True
 */
        __pyx_t_2 = __pyx_v_i;
        __pyx_t_3 = __pyx_v_water_orientation;
        __pyx_t_4 = __pyx_v_neighbor_orientation;
        __pyx_v_combination_possible = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=2 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_possible_combinations.data + __pyx_t_2 * __pyx_v_possible_combinations.strides[0]) ) + __pyx_t_3 * __pyx_v_possible_combinations.strides[1]) )) + __pyx_t_4)) )));
 2420:                 if combination_possible:
        /* "water_algorithm_cython.pyx":2420
 *             for neighbor_orientation from 0 <= neighbor_orientation < 6:
 *                 combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *                 if combination_possible:             # <<<<<<<<<<<<<<
 *                     return True
 *         return False
 */
        if (__pyx_v_combination_possible) {
 2421:                     return True
          /* "water_algorithm_cython.pyx":2421
 *                 combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *                 if combination_possible:
 *                     return True             # <<<<<<<<<<<<<<
 *         return False
 *     else:
 */
          __pyx_r = 1;
          goto __pyx_L0;
          goto __pyx_L8;
        }
        __pyx_L8:;
      }
    }
 2422:         return False
    /* "water_algorithm_cython.pyx":2422
 *                 if combination_possible:
 *                     return True
 *         return False             # <<<<<<<<<<<<<<
 *     else:
 *         for i from 0 <= i < N:
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {
 2423:     else:
 2424:         for i from 0 <= i < N:
    /* "water_algorithm_cython.pyx":2424
 *         return False
 *     else:
 *         for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *             neighbor_no = nn[i]
 *             neighbor_orientation = water_orient[neighbor_no]
 */
    __pyx_t_1 = __pyx_v_N;
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {
 2425:             neighbor_no = nn[i]
      /* "water_algorithm_cython.pyx":2425
 *     else:
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]             # <<<<<<<<<<<<<<
 *             neighbor_orientation = water_orient[neighbor_no]
 *             if neighbor_orientation == -1:
 */
      __pyx_t_5 = __pyx_v_i;
      __pyx_v_neighbor_no = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nn.data) + __pyx_t_5)) )));
 2426:             neighbor_orientation = water_orient[neighbor_no]
      /* "water_algorithm_cython.pyx":2426
 *         for i from 0 <= i < N:
 *             neighbor_no = nn[i]
 *             neighbor_orientation = water_orient[neighbor_no]             # <<<<<<<<<<<<<<
 *             if neighbor_orientation == -1:
 *                 continue
 */
      __pyx_t_6 = __pyx_v_neighbor_no;
      __pyx_v_neighbor_orientation = (*((__pyx_t_22water_algorithm_cython_DTYPE2_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE2_t *) __pyx_v_water_orient.data) + __pyx_t_6)) )));
 2427:             if neighbor_orientation == -1:
      /* "water_algorithm_cython.pyx":2427
 *             neighbor_no = nn[i]
 *             neighbor_orientation = water_orient[neighbor_no]
 *             if neighbor_orientation == -1:             # <<<<<<<<<<<<<<
 *                 continue
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 */
      __pyx_t_7 = (__pyx_v_neighbor_orientation == -1);
      if (__pyx_t_7) {
 2428:                 continue
        /* "water_algorithm_cython.pyx":2428
 *             neighbor_orientation = water_orient[neighbor_no]
 *             if neighbor_orientation == -1:
 *                 continue             # <<<<<<<<<<<<<<
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *             if combination_possible == 0:
 */
        goto __pyx_L9_continue;
        goto __pyx_L11;
      }
      __pyx_L11:;
 2429:             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
      /* "water_algorithm_cython.pyx":2429
 *             if neighbor_orientation == -1:
 *                 continue
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]             # <<<<<<<<<<<<<<
 *             if combination_possible == 0:
 *                 return False
 */
      __pyx_t_8 = __pyx_v_i;
      __pyx_t_9 = __pyx_v_water_orientation;
      __pyx_t_10 = __pyx_v_neighbor_orientation;
      __pyx_v_combination_possible = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=2 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_possible_combinations.data + __pyx_t_8 * __pyx_v_possible_combinations.strides[0]) ) + __pyx_t_9 * __pyx_v_possible_combinations.strides[1]) )) + __pyx_t_10)) )));
 2430:             if combination_possible == 0:
      /* "water_algorithm_cython.pyx":2430
 *                 continue
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *             if combination_possible == 0:             # <<<<<<<<<<<<<<
 *                 return False
 *         return True
 */
      __pyx_t_7 = (__pyx_v_combination_possible == 0);
      if (__pyx_t_7) {
 2431:                 return False
        /* "water_algorithm_cython.pyx":2431
 *             combination_possible = possible_combinations[i, water_orientation, neighbor_orientation]
 *             if combination_possible == 0:
 *                 return False             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
        __pyx_r = 0;
        goto __pyx_L0;
        goto __pyx_L12;
      }
      __pyx_L12:;
      __pyx_L9_continue:;
    }
 2432:         return True
    /* "water_algorithm_cython.pyx":2432
 *             if combination_possible == 0:
 *                 return False
 *         return True             # <<<<<<<<<<<<<<
 * 
 * cdef inline DTYPE2_t[:, ::1] stack(DTYPE2_t[:, ::1] a, DTYPE2_t[:, ::1] b):
 */
    __pyx_r = 1;
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2433: 
 2434: cdef inline DTYPE2_t[:, ::1] stack(DTYPE2_t[:, ::1] a, DTYPE2_t[:, ::1] b):
/* "water_algorithm_cython.pyx":2434
 *         return True
 * 
 * cdef inline DTYPE2_t[:, ::1] stack(DTYPE2_t[:, ::1] a, DTYPE2_t[:, ::1] b):             # <<<<<<<<<<<<<<
 *     cdef unsigned int a_length = a.shape[0], b_length = b.shape[0], N = a.shape[1], new_length
 *     cdef DTYPE2_t[:, ::1] result
 */

static CYTHON_INLINE __Pyx_memviewslice __pyx_f_22water_algorithm_cython_stack(__Pyx_memviewslice __pyx_v_a, __Pyx_memviewslice __pyx_v_b) {
  unsigned int __pyx_v_a_length;
  unsigned int __pyx_v_b_length;
  unsigned int __pyx_v_N;
  unsigned int __pyx_v_new_length;
  __Pyx_memviewslice __pyx_v_result = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_newsize = 0;
  __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stack", 0);
 2435:     cdef unsigned int a_length = a.shape[0], b_length = b.shape[0], N = a.shape[1], new_length
  /* "water_algorithm_cython.pyx":2435
 * 
 * cdef inline DTYPE2_t[:, ::1] stack(DTYPE2_t[:, ::1] a, DTYPE2_t[:, ::1] b):
 *     cdef unsigned int a_length = a.shape[0], b_length = b.shape[0], N = a.shape[1], new_length             # <<<<<<<<<<<<<<
 *     cdef DTYPE2_t[:, ::1] result
 *     cdef tuple newsize
 */
  __pyx_v_a_length = (__pyx_v_a.shape[0]);
  __pyx_v_b_length = (__pyx_v_b.shape[0]);
  __pyx_v_N = (__pyx_v_a.shape[1]);
 2436:     cdef DTYPE2_t[:, ::1] result
 2437:     cdef tuple newsize
 2438:     if b_length != 0:
  /* "water_algorithm_cython.pyx":2438
 *     cdef DTYPE2_t[:, ::1] result
 *     cdef tuple newsize
 *     if b_length != 0:             # <<<<<<<<<<<<<<
 *         new_length = a_length+b_length
 *         newsize = (new_length, N)
 */
  __pyx_t_1 = (__pyx_v_b_length != 0);
  if (__pyx_t_1) {
 2439:         new_length = a_length+b_length
    /* "water_algorithm_cython.pyx":2439
 *     cdef tuple newsize
 *     if b_length != 0:
 *         new_length = a_length+b_length             # <<<<<<<<<<<<<<
 *         newsize = (new_length, N)
 *         result = np.ndarray(newsize, dtype=DTYPE2)
 */
    __pyx_v_new_length = (__pyx_v_a_length + __pyx_v_b_length);
 2440:         newsize = (new_length, N)
    /* "water_algorithm_cython.pyx":2440
 *     if b_length != 0:
 *         new_length = a_length+b_length
 *         newsize = (new_length, N)             # <<<<<<<<<<<<<<
 *         result = np.ndarray(newsize, dtype=DTYPE2)
 *         result[:a_length] = a
 */
    __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_new_length); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_v_newsize = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
 2441:         result = np.ndarray(newsize, dtype=DTYPE2)
    /* "water_algorithm_cython.pyx":2441
 *         new_length = a_length+b_length
 *         newsize = (new_length, N)
 *         result = np.ndarray(newsize, dtype=DTYPE2)             # <<<<<<<<<<<<<<
 *         result[:a_length] = a
 *         result[a_length:] = b
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_newsize));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_newsize));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_newsize));
    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__DTYPE2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_ndarray)), ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_nn___pyx_t_22water_algorithm_cython_DTYPE2_t(__pyx_t_2);
    if (unlikely(!__pyx_t_5.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_result = __pyx_t_5;
    __pyx_t_5.memview = NULL;
    __pyx_t_5.data = NULL;
 2442:         result[:a_length] = a
    /* "water_algorithm_cython.pyx":2442
 *         newsize = (new_length, N)
 *         result = np.ndarray(newsize, dtype=DTYPE2)
 *         result[:a_length] = a             # <<<<<<<<<<<<<<
 *         result[a_length:] = b
 *         return result
 */
    __pyx_t_7 = -1;
    __pyx_t_6.data = __pyx_v_result.data;
    __pyx_t_6.memview = __pyx_v_result.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
    if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_6,
    __pyx_v_result.shape[0], __pyx_v_result.strides[0], __pyx_v_result.suboffsets[0],
    0,
    0,
    &__pyx_t_7,
    0,
    __pyx_v_a_length,
    0,
    0,
    1,
    0,
    1) < 0))
{
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}

__pyx_t_6.shape[1] = __pyx_v_result.shape[1];
__pyx_t_6.strides[1] = __pyx_v_result.strides[1];
    __pyx_t_6.suboffsets[1] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_v_a, __pyx_t_6, 2, 2, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
 2443:         result[a_length:] = b
    /* "water_algorithm_cython.pyx":2443
 *         result = np.ndarray(newsize, dtype=DTYPE2)
 *         result[:a_length] = a
 *         result[a_length:] = b             # <<<<<<<<<<<<<<
 *         return result
 *     else:
 */
    __pyx_t_7 = -1;
    __pyx_t_8.data = __pyx_v_result.data;
    __pyx_t_8.memview = __pyx_v_result.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_8, 0);
    if (unlikely(__pyx_memoryview_slice_memviewslice(
    &__pyx_t_8,
    __pyx_v_result.shape[0], __pyx_v_result.strides[0], __pyx_v_result.suboffsets[0],
    0,
    0,
    &__pyx_t_7,
    __pyx_v_a_length,
    0,
    0,
    1,
    0,
    0,
    1) < 0))
{
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}

__pyx_t_8.shape[1] = __pyx_v_result.shape[1];
__pyx_t_8.strides[1] = __pyx_v_result.strides[1];
    __pyx_t_8.suboffsets[1] = -1;

if (unlikely(__pyx_memoryview_copy_contents(__pyx_v_b, __pyx_t_8, 2, 2, 0) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
 2444:         return result
    /* "water_algorithm_cython.pyx":2444
 *         result[:a_length] = a
 *         result[a_length:] = b
 *         return result             # <<<<<<<<<<<<<<
 *     else:
 *         return a
 */
    __PYX_INC_MEMVIEW(&__pyx_v_result, 0);
    __pyx_r = __pyx_v_result;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {
 2445:     else:
 2446:         return a
    /* "water_algorithm_cython.pyx":2446
 *         return result
 *     else:
 *         return a             # <<<<<<<<<<<<<<
 * 
 * cdef np.ndarray[np.float_t, ndim=1] get_nn_com(int molecule_no, DTYPE_t[::1] nearest_neighbors_nos, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nn_periodicity_axis, np.float_t[:, ::1] cell):
 */
    __PYX_INC_MEMVIEW(&__pyx_v_a, 0);
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __pyx_r.data = NULL;
  __pyx_r.memview = NULL;
  __Pyx_AddTraceback("water_algorithm_cython.stack", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = __pyx_r;
  goto __pyx_L2;
  __pyx_L0:;
  if (unlikely(!__pyx_r.memview)) {
    PyErr_SetString(PyExc_TypeError,"Memoryview return value is not initialized");
  }
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_result, 1);
  __Pyx_XDECREF(__pyx_v_newsize);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2447: 
 2448: cdef np.ndarray[np.float_t, ndim=1] get_nn_com(int molecule_no, DTYPE_t[::1] nearest_neighbors_nos, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nn_periodicity_axis, np.float_t[:, ::1] cell):
/* "water_algorithm_cython.pyx":2448
 *         return a
 * 
 * cdef np.ndarray[np.float_t, ndim=1] get_nn_com(int molecule_no, DTYPE_t[::1] nearest_neighbors_nos, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nn_periodicity_axis, np.float_t[:, ::1] cell):             # <<<<<<<<<<<<<<
 *     cdef list com_coordinates = []
 *     cdef int n, N = nearest_neighbors_nos.shape[0]
 */

static PyArrayObject *__pyx_f_22water_algorithm_cython_get_nn_com(int __pyx_v_molecule_no, __Pyx_memviewslice __pyx_v_nearest_neighbors_nos, __Pyx_memviewslice __pyx_v_oxygen_positions, __Pyx_memviewslice __pyx_v_nn_periodicity_axis, __Pyx_memviewslice __pyx_v_cell) {
  PyObject *__pyx_v_com_coordinates = 0;
  int __pyx_v_n;
  int __pyx_v_N;
  __pyx_t_22water_algorithm_cython_DTYPE_t __pyx_v_x;
  PyObject *__pyx_v_position = NULL;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_nn_com", 0);
 2449:     cdef list com_coordinates = []
  /* "water_algorithm_cython.pyx":2449
 * 
 * cdef np.ndarray[np.float_t, ndim=1] get_nn_com(int molecule_no, DTYPE_t[::1] nearest_neighbors_nos, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nn_periodicity_axis, np.float_t[:, ::1] cell):
 *     cdef list com_coordinates = []             # <<<<<<<<<<<<<<
 *     cdef int n, N = nearest_neighbors_nos.shape[0]
 *     cdef DTYPE_t x
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_com_coordinates = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 2450:     cdef int n, N = nearest_neighbors_nos.shape[0]
  /* "water_algorithm_cython.pyx":2450
 * cdef np.ndarray[np.float_t, ndim=1] get_nn_com(int molecule_no, DTYPE_t[::1] nearest_neighbors_nos, np.float_t[:, ::1] oxygen_positions, DTYPE_t[::1] nn_periodicity_axis, np.float_t[:, ::1] cell):
 *     cdef list com_coordinates = []
 *     cdef int n, N = nearest_neighbors_nos.shape[0]             # <<<<<<<<<<<<<<
 *     cdef DTYPE_t x
 *     for n from 0 <= n < N:
 */
  __pyx_v_N = (__pyx_v_nearest_neighbors_nos.shape[0]);
 2451:     cdef DTYPE_t x
 2452:     for n from 0 <= n < N:
  /* "water_algorithm_cython.pyx":2452
 *     cdef int n, N = nearest_neighbors_nos.shape[0]
 *     cdef DTYPE_t x
 *     for n from 0 <= n < N:             # <<<<<<<<<<<<<<
 *         x = nearest_neighbors_nos[n]
 *         if molecule_no != x:
 */
  __pyx_t_2 = __pyx_v_N;
  for (__pyx_v_n = 0; __pyx_v_n < __pyx_t_2; __pyx_v_n++) {
 2453:         x = nearest_neighbors_nos[n]
    /* "water_algorithm_cython.pyx":2453
 *     cdef DTYPE_t x
 *     for n from 0 <= n < N:
 *         x = nearest_neighbors_nos[n]             # <<<<<<<<<<<<<<
 *         if molecule_no != x:
 *             if nn_periodicity_axis[n] == 13:
 */
    __pyx_t_3 = __pyx_v_n;
    __pyx_v_x = (*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nearest_neighbors_nos.data) + __pyx_t_3)) )));
 2454:         if molecule_no != x:
    /* "water_algorithm_cython.pyx":2454
 *     for n from 0 <= n < N:
 *         x = nearest_neighbors_nos[n]
 *         if molecule_no != x:             # <<<<<<<<<<<<<<
 *             if nn_periodicity_axis[n] == 13:
 *                 com_coordinates.append(oxygen_positions.base[x])
 */
    __pyx_t_4 = (__pyx_v_molecule_no != __pyx_v_x);
    if (__pyx_t_4) {
 2455:             if nn_periodicity_axis[n] == 13:
      /* "water_algorithm_cython.pyx":2455
 *         x = nearest_neighbors_nos[n]
 *         if molecule_no != x:
 *             if nn_periodicity_axis[n] == 13:             # <<<<<<<<<<<<<<
 *                 com_coordinates.append(oxygen_positions.base[x])
 *             else:
 */
      __pyx_t_5 = __pyx_v_n;
      __pyx_t_4 = ((*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nn_periodicity_axis.data) + __pyx_t_5)) ))) == 13);
      if (__pyx_t_4) {
 2456:                 com_coordinates.append(oxygen_positions.base[x])
        /* "water_algorithm_cython.pyx":2456
 *         if molecule_no != x:
 *             if nn_periodicity_axis[n] == 13:
 *                 com_coordinates.append(oxygen_positions.base[x])             # <<<<<<<<<<<<<<
 *             else:
 *                 position = oxygen_positions.base[x] + np.dot(cell, get_vector_from_periodicity_axis_number(nn_periodicity_axis[n]))
 */
        __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_oxygen_positions, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, __pyx_v_x, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_com_coordinates, __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L6;
      }
      /*else*/ {
 2457:             else:
 2458:                 position = oxygen_positions.base[x] + np.dot(cell, get_vector_from_periodicity_axis_number(nn_periodicity_axis[n]))
        /* "water_algorithm_cython.pyx":2458
 *                 com_coordinates.append(oxygen_positions.base[x])
 *             else:
 *                 position = oxygen_positions.base[x] + np.dot(cell, get_vector_from_periodicity_axis_number(nn_periodicity_axis[n]))             # <<<<<<<<<<<<<<
 *                 com_coordinates.append(position)
 * 
 */
        __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_oxygen_positions, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__base); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_6, __pyx_v_x, sizeof(__pyx_t_22water_algorithm_cython_DTYPE_t)+1, __Pyx_PyInt_to_py_npy_uint8, 0, 0, 0); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s__dot); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_cell, 2, (PyObject *(*)(char *)) __pyx_memview_get_nn___pyx_t_5numpy_float_t, (int (*)(char *, PyObject *)) __pyx_memview_set_nn___pyx_t_5numpy_float_t, 0);; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_9 = __pyx_v_n;
        __pyx_t_10 = ((PyObject *)__pyx_f_22water_algorithm_cython_get_vector_from_periodicity_axis_number((*((__pyx_t_22water_algorithm_cython_DTYPE_t *) ( /* dim=0 */ ((char *) (((__pyx_t_22water_algorithm_cython_DTYPE_t *) __pyx_v_nn_periodicity_axis.data) + __pyx_t_9)) ))))); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_t_6 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Add(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_v_position);
        __pyx_v_position = __pyx_t_11;
        __pyx_t_11 = 0;
 2459:                 com_coordinates.append(position)
        /* "water_algorithm_cython.pyx":2459
 *             else:
 *                 position = oxygen_positions.base[x] + np.dot(cell, get_vector_from_periodicity_axis_number(nn_periodicity_axis[n]))
 *                 com_coordinates.append(position)             # <<<<<<<<<<<<<<
 * 
 *     return get_oxygens(np.array(com_coordinates)).get_center_of_mass()
 */
        __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_com_coordinates, __pyx_v_position); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }
 2460: 
 2461:     return get_oxygens(np.array(com_coordinates)).get_center_of_mass()
  /* "water_algorithm_cython.pyx":2461
 *                 com_coordinates.append(position)
 * 
 *     return get_oxygens(np.array(com_coordinates)).get_center_of_mass()             # <<<<<<<<<<<<<<
 * 
 * @cython.cdivision(True)
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s__get_oxygens); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s__np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(((PyObject *)__pyx_v_com_coordinates));
  PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_com_coordinates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_com_coordinates));
  __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s__get_center_of_mass); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("water_algorithm_cython.get_nn_com", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_com_coordinates);
  __Pyx_XDECREF(__pyx_v_position);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 2462: 
 2463: @cython.cdivision(True)
 2464: cdef inline void add_to_dipole_moment_estimate(np.float_t[::1] h_coordinate, np.float_t[::1] o_coordinate, np.float_t O_H_distance, np.float_t[::1] dipole_moment):
/* "water_algorithm_cython.pyx":2464
 * 
 * @cython.cdivision(True)
 * cdef inline void add_to_dipole_moment_estimate(np.float_t[::1] h_coordinate, np.float_t[::1] o_coordinate, np.float_t O_H_distance, np.float_t[::1] dipole_moment):             # <<<<<<<<<<<<<<
 *     cdef int i, N = 3
 *     for i from 0 <= i < N:
 */

static CYTHON_INLINE void __pyx_f_22water_algorithm_cython_add_to_dipole_moment_estimate(__Pyx_memviewslice __pyx_v_h_coordinate, __Pyx_memviewslice __pyx_v_o_coordinate, __pyx_t_5numpy_float_t __pyx_v_O_H_distance, __Pyx_memviewslice __pyx_v_dipole_moment) {
  int __pyx_v_i;
  int __pyx_v_N;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_to_dipole_moment_estimate", 0);
 2465:     cdef int i, N = 3
  /* "water_algorithm_cython.pyx":2465
 * @cython.cdivision(True)
 * cdef inline void add_to_dipole_moment_estimate(np.float_t[::1] h_coordinate, np.float_t[::1] o_coordinate, np.float_t O_H_distance, np.float_t[::1] dipole_moment):
 *     cdef int i, N = 3             # <<<<<<<<<<<<<<
 *     for i from 0 <= i < N:
 *         dipole_moment[i] += ( h_coordinate[i] - o_coordinate[i] ) / (O_H_distance * 2)
 */
  __pyx_v_N = 3;
 2466:     for i from 0 <= i < N:
  /* "water_algorithm_cython.pyx":2466
 * cdef inline void add_to_dipole_moment_estimate(np.float_t[::1] h_coordinate, np.float_t[::1] o_coordinate, np.float_t O_H_distance, np.float_t[::1] dipole_moment):
 *     cdef int i, N = 3
 *     for i from 0 <= i < N:             # <<<<<<<<<<<<<<
 *         dipole_moment[i] += ( h_coordinate[i] - o_coordinate[i] ) / (O_H_distance * 2)
 * 
 */
  __pyx_t_1 = __pyx_v_N;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {
 2467:         dipole_moment[i] += ( h_coordinate[i] - o_coordinate[i] ) / (O_H_distance * 2)
    /* "water_algorithm_cython.pyx":2467
 *     cdef int i, N = 3
 *     for i from 0 <= i < N:
 *         dipole_moment[i] += ( h_coordinate[i] - o_coordinate[i] ) / (O_H_distance * 2)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_2 = __pyx_v_i;
    __pyx_t_3 = __pyx_v_i;
    __pyx_t_4 = __pyx_v_i;
    *((__pyx_t_5numpy_float_t *) ( /* dim=0 */ ((char *) (((__pyx_t_5numpy_float_t *) __pyx_v_dipole_moment.data) + __pyx_t_4)) )) += (((*((__pyx_t_5numpy_float_t *) ( /* dim=0 */ ((char *) (((__pyx_t_5numpy_float_t *) __pyx_v_h_coordinate.data) + __pyx_t_2)) ))) - (*((__pyx_t_5numpy_float_t *) ( /* dim=0 */ ((char *) (((__pyx_t_5numpy_float_t *) __pyx_v_o_coordinate.data) + __pyx_t_3)) )))) / (__pyx_v_O_H_distance * 2.0));
  }

  __Pyx_RefNannyFinishContext();
}
 2468: 
 2469: 
 2470: include "help_methods_cython.pyx"